main
1using System;
2using System.Collections.Generic;
3using developwithpassion.bdd.contexts;
4using Gorilla.Commons.Testing;
5using MoMoney.Domain.Accounting;
6using MoMoney.Domain.Core;
7
8namespace MoMoney.Domain.accounting
9{
10 [Concern(typeof (GeneralLedger))]
11 public abstract class behaves_like_a_general_ledger : concerns_for<IGeneralLedger, GeneralLedger>
12 {
13 public override IGeneralLedger create_sut()
14 {
15 return new GeneralLedger(new List<ILedgerEntry> {february_first, february_twenty_first, april_first});
16 }
17
18 context c = () =>
19 {
20 february_first = an<ILedgerEntry>();
21 february_twenty_first = an<ILedgerEntry>();
22 april_first = an<ILedgerEntry>();
23 };
24
25 protected static ILedgerEntry february_first;
26 protected static ILedgerEntry february_twenty_first;
27 protected static ILedgerEntry april_first;
28 }
29
30 public class when_retrieving_all_the_entries_for_a_month_in_the_past : behaves_like_a_general_ledger
31 {
32 it should_return_all_the_entries_posted_for_that_month = () =>
33 {
34 result.should_contain(february_first);
35 result.should_contain(february_twenty_first);
36 };
37
38 it should_not_return_any_entries_that_were_not_posted_for_that_month =
39 () => result.should_not_contain(april_first);
40
41 context c = () =>
42 {
43 february_first = an<ILedgerEntry>();
44 february_twenty_first = an<ILedgerEntry>();
45 april_first = an<ILedgerEntry>();
46
47 february_first.is_told_to(x => x.entry_date()).it_will_return(new DateTime(2008, 02, 01));
48 february_twenty_first.is_told_to(x => x.entry_date()).it_will_return(new DateTime(2008, 02, 21));
49 april_first.is_told_to(x => x.entry_date()).it_will_return(new DateTime(2008, 04, 01));
50 };
51
52 because b = () => { result = sut.get_all_the_entries_for(Months.February); };
53
54 static IEnumerable<ILedgerEntry> result;
55 }
56}