main
 1namespace test
 2{
 3  using System.Collections.Generic;
 4  using Machine.Specifications;
 5  using domain;
 6
 7  public class RangeSpecs
 8  {
 9    Establish context = () =>
10    {
11      sut = new Range<Month>(new Month(2012, 01), new Month(2012, 03));
12    };
13
14    static IRange<Month> sut;
15
16    public class when_iterating_through_each_item_in_a_range
17    {
18      It should_visit_each_item_in_the_range =()=>
19      {
20        results.ShouldContainOnly(new Month(2012, 01),new Month(2012, 02),new Month(2012, 03));
21      };
22
23      Because of = () =>
24      {
25        sut.Accept(x =>
26            {
27            results.Add(x);
28            });
29      };
30
31      static IList<Month> results = new List<Month>();
32    }
33    public class when_a_range_contains_an_item
34    {
35      It should_return_true=()=>
36      {
37        result.ShouldBeTrue();
38      };
39
40      Because of = ()=>
41      {
42        result = sut.Contains(new Month(2012, 02));
43      };
44
45      static bool result;
46    }
47    public class when_an_item_is_before_the_range{
48      It should_return_false=()=>
49      {
50        var result = sut.Contains(new Month(2011, 12));
51        result.ShouldBeFalse();
52      };
53    }
54    public class when_an_item_is_after_the_range{
55      It should_return_false=()=>
56      {
57        var result = sut.Contains(new Month(2012, 04));
58        result.ShouldBeFalse();
59      };
60    }
61  }
62}