summaryrefslogtreecommitdiff
path: root/product/Presentation/Presenters/AddNewIncomePresenterSpecs.cs
blob: 5ba73feacb2ca56d5ff042e20e9b8a923a693d30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Collections.Generic;
using developwithpassion.bdd.contexts;
using Gorilla.Commons.Testing;
using MoMoney.DTO;
using MoMoney.Presentation.Views;
using MoMoney.Service.Contracts.Application;

namespace MoMoney.Presentation.Presenters
{
    [Concern(typeof (AddNewIncomePresenter))]
    public abstract class behaves_like_add_new_income_presenter :
        concerns_for<IAddNewIncomePresenter, AddNewIncomePresenter>
    {
        context c = () =>
        {
            view = the_dependency<IAddNewIncomeView>();
            pump = the_dependency<ICommandPump>();
        };

        static protected ICommandPump pump;
        static protected IAddNewIncomeView view;
    }

    [Concern(typeof (AddNewIncomePresenter))]
    public class when_new_income_is_submitted : behaves_like_add_new_income_presenter
    {
        it should_add_the_income_to_the_account_holders_account =
            () => pump.was_told_to(x => x.run<IAddNewIncomeCommand, IncomeSubmissionDTO>(income));

        it should_display_the_new_income =
            () => pump.was_told_to(x => x.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view));

        context c = () => { income = new IncomeSubmissionDTO {}; };

        because b = () => sut.submit_new(income);

        static IncomeSubmissionDTO income;
    }

    [Concern(typeof (AddNewIncomePresenter))]
    public class when_loaded : behaves_like_add_new_income_presenter
    {
        it should_display_a_list_of_all_the_registered_company_to_select =
            () => pump.was_told_to(x => x.run<IEnumerable<CompanyDTO>, IGetAllCompanysQuery>(view));

        it should_bind_a_presenter_to_the_screen = () => view.was_told_to(x => x.attach_to(sut));

        it should_display_the_income_already_added =
            () => pump.was_told_to(x => x.run<IEnumerable<IncomeInformationDTO>, IGetAllIncomeQuery>(view));

        context c = () => { };

        because b = () => sut.run();
    }
}