main
1using System.Collections.Generic;
2using developwithpassion.bdd.contexts;
3using Gorilla.Commons.Testing;
4using MoMoney.DTO;
5using MoMoney.Presentation.Presenters;
6using MoMoney.Presentation.Views;
7using MoMoney.Service.Contracts.Application;
8
9namespace momoney.presentation.presenters
10{
11 [Concern(typeof (AddNewIncomePresenter))]
12 public abstract class behaves_like_add_new_income_presenter :
13 concerns_for<IAddNewIncomePresenter, AddNewIncomePresenter>
14 {
15 context c = () =>
16 {
17 view = the_dependency<IAddNewIncomeView>();
18 pump = the_dependency<ICommandPump>();
19 };
20
21 static protected ICommandPump pump;
22 static protected IAddNewIncomeView view;
23 }
24
25 [Concern(typeof (AddNewIncomePresenter))]
26 public class when_new_income_is_submitted : behaves_like_add_new_income_presenter
27 {
28 it should_add_the_income_to_the_account_holders_account =
29 () => pump.was_told_to(x => x.run<IAddNewIncomeCommand, IncomeSubmissionDTO>(income));
30
31 it should_display_the_new_income =
32 () => pump.was_told_to(x => x.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view));
33
34 context c = () => { income = new IncomeSubmissionDTO {}; };
35
36 because b = () => sut.submit_new(income);
37
38 static IncomeSubmissionDTO income;
39 }
40
41 [Concern(typeof (AddNewIncomePresenter))]
42 public class when_loaded : behaves_like_add_new_income_presenter
43 {
44 it should_display_a_list_of_all_the_registered_company_to_select =
45 () => pump.was_told_to(x => x.run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view));
46
47 it should_bind_a_presenter_to_the_screen = () => view.was_told_to(x => x.attach_to(sut));
48
49 it should_display_the_income_already_added =
50 () => pump.was_told_to(x => x.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view));
51
52 context c = () => { };
53
54 because b = () => sut.run();
55 }
56}