main
 1using developwithpassion.bdd.contexts;
 2using Gorilla.Commons.Testing;
 3using gorilla.commons.utility;
 4using Gorilla.Commons.Utility;
 5using MoMoney.Presentation.Presenters;
 6using momoney.presentation.views;
 7using momoney.service.infrastructure.updating;
 8
 9namespace momoney.presentation.presenters
10{
11    [Concern(typeof (CheckForUpdatesPresenter))]
12    public abstract class behaves_like_check_for_updates_presenter :
13        concerns_for<ICheckForUpdatesPresenter, CheckForUpdatesPresenter>
14    {
15        context c = () =>
16        {
17            view = the_dependency<ICheckForUpdatesView>();
18            pump = the_dependency<ICommandPump>();
19        };
20
21        static protected ICheckForUpdatesView view;
22        static protected ICommandPump pump;
23    }
24
25    public class when_attempting_to_check_for_updates : behaves_like_check_for_updates_presenter
26    {
27        it should_tell_the_view_to_attach_itself_to_the_presenter = () => view.was_told_to(x => x.attach_to(sut));
28
29        it should_tell_the_view_to_display_the_information_on_the_current_version_of_the_application =
30            () => view.was_told_to(x => x.display());
31
32        it should_go_and_find_out_what_the_latest_version_is =
33            () => pump.was_told_to(x => x.run<ApplicationVersion, IWhatIsTheAvailableVersion>(view));
34
35        because b = () => sut.run();
36    }
37
38    public class when_initiating_an_update_and_one_is_available : behaves_like_check_for_updates_presenter
39    {
40        it should_start_downloading_the_latest_version_of_the_application =
41            () => pump.was_told_to(x => x.run<IDownloadTheLatestVersion, Callback<Percent>>(sut));
42
43        because b = () => sut.begin_update();
44    }
45
46    public class when_downloading_an_update : behaves_like_check_for_updates_presenter
47    {
48        it should_notify_you_of_the_progress_of_the_update = () => view.was_told_to(x => x.downloaded(50));
49
50        because b = () => sut.run(50);
51    }
52
53    public class when_an_update_is_completed : behaves_like_check_for_updates_presenter
54    {
55        it should_notify_the_view_that_the_update_is_complete = () => view.was_told_to(x => x.update_complete());
56
57        because b = () => sut.run(100);
58    }
59
60    public class when_an_update_is_cancelled : behaves_like_check_for_updates_presenter
61    {
62        it should_stop_downloading_the_latest_update = () => pump.was_told_to(x => x.run<ICancelUpdate>());
63
64        because b = () => sut.cancel_update();
65    }
66
67    public class when_an_update_is_complete_and_the_user_agrees_to_restart_the_application :
68        behaves_like_check_for_updates_presenter
69    {
70        it should_restart_the_application = () => pump.was_told_to(x => x.run<IRestartCommand>());
71
72        because b = () => sut.restart();
73    }
74}