main
1using developwithpassion.bdd.contexts;
2using Gorilla.Commons.Testing;
3using momoney.presentation.model.eventing;
4using MoMoney.Presentation.Model.Projects;
5using MoMoney.Presentation.Views;
6using MoMoney.Service.Infrastructure.Eventing;
7
8namespace momoney.presentation.presenters
9{
10 [Concern(typeof (TitleBarPresenter))]
11 public abstract class behaves_like_a_title_bar_presenter : concerns_for<ITitleBarPresenter, TitleBarPresenter>
12 {
13 context c = () =>
14 {
15 project = the_dependency<IProjectController>();
16 view = the_dependency<ITitleBar>();
17 broker = the_dependency<IEventAggregator>();
18 };
19
20 protected static ITitleBar view;
21 protected static IEventAggregator broker;
22 protected static IProjectController project;
23 }
24
25 public class when_initializing_the_title_bar_for_the_first_time : behaves_like_a_title_bar_presenter
26 {
27 it should_display_the_name_of_the_file_that_is_opened = () => view.was_told_to(x => x.display("untitled.mo"));
28
29 it should_ask_to_be_notified_of_any_unsaved_changes =
30 () => broker.was_told_to(x => x.subscribe_to<UnsavedChangesEvent>(sut));
31
32 it should_ask_to_be_notified_when_the_project_is_saved =
33 () => broker.was_told_to(x => x.subscribe_to<SavedChangesEvent>(sut));
34
35 it should_ask_to_be_notified_when_a_new_project_is_opened =
36 () => broker.was_told_to(x => x.subscribe_to<NewProjectOpened>(sut));
37
38 context c = () => when_the(project).is_told_to(x => x.name()).it_will_return("untitled.mo");
39
40 because b = () => sut.run();
41 }
42
43 public class when_there_are_unsaved_changes_in_the_project : behaves_like_a_title_bar_presenter
44 {
45 it should_display_an_asterik_in_the_title = () => view.was_told_to(x => x.append_asterik());
46
47 context c = () => { dto = new UnsavedChangesEvent(); };
48
49 because b = () => sut.notify(dto);
50
51 static UnsavedChangesEvent dto;
52 }
53}