main
1using System;
2using Machine.Specifications;
3using solidware.financials.service.domain;
4using solidware.financials.service.domain.payroll;
5
6namespace specs.unit.service.domain.payroll
7{
8 public class GrantSpecs
9 {
10 public abstract class concern
11 {
12 Establish context = () =>
13 {
14 Calendar.freeze(() => new DateTime(2010, 01, 01));
15 sut = Grant.New(120, 10, new One<Twelfth>(), new Monthly());
16 };
17
18 Cleanup clean = () =>
19 {
20 Calendar.thaw();
21 };
22
23 static protected Grant sut;
24 }
25
26 [Concern(typeof (Grant))]
27 public class when_checking_what_the_outstanding_balance_of_a_grant_is : concern
28 {
29 It should_return_the_full_balance_before_the_first_vesting_date = () =>
30 {
31 Calendar.freeze(() => new DateTime(2010, 01, 31));
32 sut.balance().should_be_equal_to(120);
33 };
34
35 It should_return_the_unvested_portion_after_the_first_vesting_date = () =>
36 {
37 Calendar.freeze(() => new DateTime(2010, 02, 01));
38 sut.balance().should_be_equal_to(110);
39 };
40 }
41
42 [Concern(typeof (Grant))]
43 public class when_checking_what_the_value_of_a_grant_was_in_the_past : concern
44 {
45 Because b = () =>
46 {
47 Calendar.freeze(() => january_15);
48 sut.change_unit_price_to(20);
49
50 Calendar.thaw();
51 sut.change_unit_price_to(40);
52 result = sut.balance(january_15);
53 };
54
55 It should_return_the_correct_amount = () =>
56 {
57 result.should_be_equal_to(240);
58 };
59
60 static Money result;
61 static Date january_15 = new DateTime(2010, 01, 15);
62 }
63 }
64}