main
 1using developwithpassion.bdd.contexts;
 2using Gorilla.Commons.Testing;
 3using MoMoney.Presentation.Core;
 4using momoney.presentation.model.eventing;
 5using MoMoney.Presentation.Model.Menu.File;
 6using MoMoney.Service.Infrastructure.Eventing;
 7
 8namespace momoney.presentation.model.menu.file
 9{
10    [Concern(typeof (ExitCommand))]
11    public abstract class behaves_like_exit_command : concerns_for<IExitCommand>
12    {
13        public override IExitCommand create_sut()
14        {
15            return new ExitCommand(application, broker, save_changes_command);
16        }
17
18        context c = () =>
19        {
20            application = the_dependency<IApplication>();
21            broker = the_dependency<IEventAggregator>();
22            save_changes_command = the_dependency<ISaveChangesCommand>();
23        };
24
25        protected static IApplication application;
26        protected static IEventAggregator broker;
27        protected static ISaveChangesCommand save_changes_command;
28    }
29
30    public class when_closing_the_application_after_saving_the_project : behaves_like_exit_command
31    {
32        it should_ask_the_application_environment_to_shut_down = () => application.was_told_to(x => x.shut_down());
33
34        it should_publish_the_shut_down_event = () => broker.was_told_to(x => x.publish<ClosingTheApplication>());
35
36        because b = () => sut.saved();
37    }
38
39    public class when_closing_the_application_after_declining_to_save_the_project : behaves_like_exit_command
40    {
41        it should_ask_the_application_environment_to_shut_down = () => application.was_told_to(x => x.shut_down());
42
43        it should_publish_the_shut_down_event = () => broker.was_told_to(x => x.publish<ClosingTheApplication>());
44
45        because b = () => sut.not_saved();
46    }
47
48    public class when_closing_the_application_after_clicking_cancel_when_prompted_to_save_changes :
49        behaves_like_exit_command
50    {
51        it should_not_ask_the_application_environment_to_shut_down = () => application.was_told_to(x => x.shut_down());
52
53        it should_not_publish_the_shut_down_event = () => broker.was_told_to(x => x.publish<ClosingTheApplication>());
54
55        because b = () => sut.not_saved();
56    }
57}