main
1using System;
2using developwithpassion.bdd.contexts;
3using Gorilla.Commons.Testing;
4using momoney.presentation.views;
5using MoMoney.Service.Infrastructure.Threading;
6
7namespace MoMoney.Presentation.Presenters
8{
9 [Concern(typeof (SplashScreenPresenter))]
10 public abstract class behaves_like_splash_screen_presenter : concerns_for<ISplashScreenPresenter>
11 {
12 public override ISplashScreenPresenter create_sut()
13 {
14 return new SplashScreenPresenter(timer, view);
15 }
16
17 context c = () =>
18 {
19 timer = the_dependency<ITimer>();
20 view = the_dependency<ISplashScreenView>();
21 };
22
23 protected static ITimer timer;
24 protected static ISplashScreenView view;
25 }
26
27 public class when_displaying_the_splash_screen : behaves_like_splash_screen_presenter
28 {
29 it should_start_a_timer_that_increments_the_opacity =
30 () => timer.was_told_to(t => t.start_notifying(sut, new TimeSpan(50)));
31
32 it should_show_the_splash_screen = () => view.was_told_to(v => v.display());
33
34 because b = () => sut.run();
35 }
36
37 public class when_the_timer_notifies_the_presenter_that_to_update : behaves_like_splash_screen_presenter
38 {
39 it should_increment_the_views_opacity = () => view.was_told_to(v => v.increment_the_opacity());
40
41 context c = () => when_the(view).is_asked_for(v => v.current_opacity()).it_will_return(0.5);
42
43 because b = () =>
44 {
45 sut.run();
46 sut.notify();
47 };
48 }
49
50 public class when_the_timer_notifies_the_presenter_to_update_and_the_opacity_of_the_view_has_reached_100_percent :
51 behaves_like_splash_screen_presenter
52 {
53 it should_stop_the_timer = () => timer.was_told_to(t => t.stop_notifying(sut));
54
55 context c = () => when_the(view).is_asked_for(v => v.current_opacity()).it_will_return(1);
56
57 because b = () =>
58 {
59 sut.run();
60 sut.notify();
61 };
62 }
63
64 public class when_hiding_the_splash_screen : behaves_like_splash_screen_presenter
65 {
66 it should_start_a_timer_to_fade_the_splash_screen_away =
67 () => timer.was_told_to(t => t.start_notifying(sut, new TimeSpan(50)));
68
69 it should_decrement_the_opacity_of_the_view = () => view.was_told_to(v => v.decrement_the_opacity());
70
71 context c = () => when_the(view).is_asked_for(v => v.current_opacity()).it_will_return(.5);
72
73 because b = () =>
74 {
75 sut.Dispose();
76 sut.notify();
77 };
78 }
79
80 public class when_the_splash_screen_is_fading_away_and_its_opacity_has_reached_zero :
81 behaves_like_splash_screen_presenter
82 {
83 it should_stop_the_timer = () => timer.was_told_to(t => t.stop_notifying(sut));
84
85 it should_close_the_view = () => view.was_told_to(v => v.close_the_screen());
86
87 context c = () => when_the(view).is_asked_for(v => v.current_opacity()).it_will_return(0);
88
89 because b = () =>
90 {
91 sut.Dispose();
92 sut.notify();
93 };
94 }
95}