main
1using Machine.Specifications;
2using solidware.financials.windows.ui;
3using solidware.financials.windows.ui.presenters;
4using solidware.financials.windows.ui.views;
5
6namespace specs.unit.ui.presenters
7{
8 public class StockViewModelSpecs
9 {
10 public abstract class concern
11 {
12 Establish context = () =>
13 {
14 builder = Create.dependency<UICommandBuilder>();
15 sut = new StockViewModel("ARX.TO", builder);
16 };
17
18 static protected StockViewModel sut;
19 static protected UICommandBuilder builder;
20 }
21
22 public class when_someone_clicks_on_the_additional_info_button : concern
23 {
24 Establish context = () =>
25 {
26 more_command = Create.an<ObservableCommand>();
27 builder.is_told_to(x => x.build<StockViewModel.MoreCommand>(sut)).it_will_return(more_command);
28 };
29
30 Because of = () =>
31 {
32 sut.present();
33 };
34
35 It should_execute_the_additional_info_command = () =>
36 {
37 sut.AdditionalInformation.should_be_equal_to(more_command);
38 };
39
40 static ObservableCommand more_command;
41 }
42
43 public class MoreCommandSpecs
44 {
45 public abstract class concern_for_more_command
46 {
47 Establish context = () =>
48 {
49 controller = Create.dependency<ApplicationController>();
50 factory = Create.dependency<SingleStockPresenter.Factory>();
51 sut = new StockViewModel.MoreCommand(controller, factory);
52 };
53
54 static protected StockViewModel.MoreCommand sut;
55 static protected ApplicationController controller;
56 static protected SingleStockPresenter.Factory factory;
57 }
58
59 public class when_wanting_to_see_more_info_on_a_stock : concern_for_more_command
60 {
61 Establish context = () =>
62 {
63 presenter = Create.an<StockViewModel>();
64 tab = Create.an<SingleStockPresenter>();
65
66 presenter.is_told_to(x => x.Symbol).it_will_return("ARX.TO");
67 factory.is_told_to(x => x.create_for("ARX.TO")).it_will_return(tab);
68 };
69
70 Because of = () =>
71 {
72 sut.run(presenter);
73 };
74
75 It should_display_a_tab_for_the_stock = () =>
76 {
77 controller.received(x => x.load_tab<SingleStockPresenter, SingleStockTab>(tab));
78 };
79
80 static StockViewModel presenter;
81 static SingleStockPresenter tab;
82 }
83 }
84 }
85}