main
 1using developwithpassion.bdd.contexts;
 2using Gorilla.Commons.Testing;
 3
 4namespace MoMoney.Domain.Core
 5{
 6    public class RangeSpecs
 7    {
 8    }
 9
10    [Concern(typeof (Range<int>))]
11    public abstract class behaves_like_a_range_from_1_to_10 : concerns_for<IRange<int>>
12    {
13        public override IRange<int> create_sut()
14        {
15            return new Range<int>(1, 10);
16        }
17    }
18
19    [Concern(typeof (Range<int>))]
20    public abstract class behaves_like_a_range_from_10_to_1 : concerns_for<IRange<int>>
21    {
22        public override IRange<int> create_sut()
23        {
24            return new Range<int>(10, 1);
25        }
26    }
27
28    public class when_a_range_from_1_to_10_is_asked_if_it_contains_the_number_1 : behaves_like_a_range_from_1_to_10
29    {
30        it should_return_true = () => result.should_be_equal_to(true);
31
32        because b = () => { result = sut.contains(1); };
33
34        static bool result;
35    }
36
37    public class when_a_range_from_1_to_10_is_asked_if_it_contains_the_number_10 : behaves_like_a_range_from_1_to_10
38    {
39        it should_return_true = () => result.should_be_equal_to(true);
40
41        because b = () => { result = sut.contains(10); };
42
43        static bool result;
44    }
45
46    public class when_a_range_from_1_to_10_is_asked_if_it_contains_the_number_0 : behaves_like_a_range_from_1_to_10
47    {
48        it should_return_false = () => result.should_be_equal_to(false);
49
50        because b = () => { result = sut.contains(0); };
51
52        static bool result;
53    }
54
55    public class when_a_range_from_1_to_10_is_asked_if_it_contains_the_number_11 : behaves_like_a_range_from_1_to_10
56    {
57        it should_return_false = () => result.should_be_equal_to(false);
58
59        because b = () => { result = sut.contains(0); };
60
61        static bool result;
62    }
63
64    public class when_a_range_is_created_where_the_start_of_the_range_is_greater_than_the_end :
65        behaves_like_a_range_from_10_to_1
66    {
67        it should_flip_the_start_and_end_of_the_range = () =>
68                                                            {
69                                                                sut.start_of_range.should_be_equal_to(1);
70                                                                sut.end_of_range.should_be_equal_to(10);
71                                                            };
72    }
73}