main
 1using developwithpassion.bdd.contexts;
 2using Gorilla.Commons.Infrastructure.FileSystem;
 3using Gorilla.Commons.Testing;
 4using MoMoney.Presentation.Model.Menu.File;
 5using MoMoney.Presentation.Model.Projects;
 6using momoney.presentation.views;
 7
 8namespace momoney.presentation.model.menu.file
 9{
10    [Concern(typeof (OpenCommand))]
11    public abstract class behaves_like_command_to_open_a_project : concerns_for<IOpenCommand, OpenCommand>
12    {
13        context c = () =>
14        {
15            view = the_dependency<ISelectFileToOpenDialog>();
16            project = the_dependency<IProjectController>();
17            save_changes_command = the_dependency<ISaveChangesCommand>();
18        };
19
20        protected static IProjectController project;
21        protected static ISelectFileToOpenDialog view;
22        protected static ISaveChangesCommand save_changes_command;
23    }
24
25    public class before_opening_a_new_project :
26        behaves_like_command_to_open_a_project
27    {
28        it should_check_to_see_if_you_want_to_save_the_previously_opened_project =
29            () => save_changes_command.was_told_to(x => x.run(sut));
30
31        because b = () => sut.run();
32    }
33
34    public class when_attempting_to_open_an_existing_project_after_saving_the_previous_project :
35        behaves_like_command_to_open_a_project
36    {
37        it should_open_the_project_at_the_file_path_specified =
38            () => project.was_told_to(x => x.open_project_from(file_path));
39
40        context c = () =>
41        {
42            file_path = "blah_blah";
43            when_the(view).is_told_to(x => x.tell_me_the_path_to_the_file()).it_will_return(file_path);
44        };
45
46        because b = () => sut.saved();
47
48        static ApplicationFile file_path;
49    }
50
51    public class when_opening_a_project_after_declining_to_save_the_previous_project :
52        behaves_like_command_to_open_a_project
53    {
54        it should_open_the_project_at_the_file_path_specified =
55            () => project.was_told_to(x => x.open_project_from(file_path));
56
57        context c = () =>
58        {
59            file_path = "blah_blah";
60            when_the(view).is_told_to(x => x.tell_me_the_path_to_the_file()).it_will_return(file_path);
61        };
62
63        because b = () => sut.not_saved();
64
65        static ApplicationFile file_path;
66    }
67
68    public class
69        when_opening_a_new_project_and_then_deciding_that_you_want_to_continue_working_on_the_previously_opened_project :
70            behaves_like_command_to_open_a_project
71    {
72        it should_not_open_the_project_at_the_file_path_specified =
73            () => project.was_not_told_to(x => x.open_project_from(file_path));
74
75        context c = () =>
76        {
77            file_path = "blah_blah";
78            when_the(view).is_told_to(x => x.tell_me_the_path_to_the_file()).it_will_return(file_path);
79        };
80
81        because b = () => sut.cancelled();
82
83        static ApplicationFile file_path;
84    }
85}