main
 1using System;
 2using gorilla.utility;
 3using Machine.Specifications;
 4using solidware.financials.messages;
 5using solidware.financials.windows.ui.presenters;
 6
 7namespace specs.unit.ui.presenters
 8{
 9    public class SingleStockPresenterSpecs
10    {
11        [Subject(typeof (SingleStockPresenter))]
12        public abstract class concern
13        {
14            Establish context = () =>
15            {
16                Clock.change_time_provider_to(() => now);
17                sut = new SingleStockPresenter("ARX.TO");
18            };
19
20            Cleanup clean = () =>
21            {
22                Clock.reset();
23            };
24
25            static protected SingleStockPresenter sut;
26            static protected DateTime now = new DateTime(2011, 01, 01);
27        }
28
29        public class when_a_new_price_is_received_for_the_stock_this_chart_is_for : concern
30        {
31            Establish context = () =>
32            {
33                current_price = new CurrentStockPrice
34                                {
35                                    Symbol = "ARX.TO",
36                                    Price = 29.00m
37                                };
38            };
39
40            Because of = () =>
41            {
42                sut.present();
43                sut.notify(current_price);
44            };
45
46            It should_update_the_chart_with_the_new_data_point = () =>
47            {
48                sut.Chart.should_contain(x => x.Key.Equals(now) && x.Value.Equals(29.00m));
49            };
50
51            static CurrentStockPrice current_price;
52        }
53
54        public class when_a_new_price_is_received_for_another_stock : concern
55        {
56            Establish context = () =>
57            {
58                current_price = new CurrentStockPrice
59                                {
60                                    Symbol = "TD.TO",
61                                    Price = 90.00m
62                                };
63            };
64
65            Because of = () =>
66            {
67                sut.present();
68                sut.notify(current_price);
69            };
70
71            It should_not_update_the_chart = () =>
72            {
73                sut.Chart.Count.should_be_equal_to(0);
74            };
75
76            static CurrentStockPrice current_price;
77        }
78
79        public class when_displaying_the_header_for_this_tab : concern
80        {
81            It should_describe_the_stock_that_it_is_for = () =>
82            {
83                sut.Header.should_be_equal_to("ARX.TO");
84            };
85        }
86    }
87}