main
1using developwithpassion.bdd.contexts;
2using Gorilla.Commons.Testing;
3using MoMoney.Presentation.Model.Projects;
4
5namespace momoney.presentation.model.menu.file
6{
7 [Concern(typeof (SaveCommand))]
8 public abstract class behaves_like_the_save_command : concerns_for<ISaveCommand, SaveCommand>
9 {
10 public override ISaveCommand create_sut()
11 {
12 return new SaveCommand(current_project, save_as_command);
13 }
14
15 context c = () =>
16 {
17 current_project = an<IProjectController>();
18 save_as_command = an<ISaveAsCommand>();
19 };
20 protected static ISaveAsCommand save_as_command;
21 protected static IProjectController current_project;
22 }
23
24 public class when_saving_the_current_project_that_has_not_been_saved_yet : behaves_like_the_save_command
25 {
26 it should_prompt_the_user_to_specifiy_the_path_to_save_to = () => save_as_command.was_told_to(x => x.run());
27
28 context c = () => when_the(current_project)
29 .is_told_to(x => x.has_been_saved_at_least_once())
30 .it_will_return(false);
31
32 because b = () => sut.run();
33
34 public override ISaveCommand create_sut()
35 {
36 return new SaveCommand(current_project, save_as_command);
37 }
38 }
39
40 [Concern(typeof (SaveCommand))]
41 public class when_saving_the_current_project_that_has_been_saved_before : behaves_like_the_save_command
42 {
43 it should_save_the_current_project_to_the_same_path = () => current_project.was_told_to(x => x.save_changes());
44
45 context c = () => when_the(current_project)
46 .is_told_to(x => x.has_been_saved_at_least_once())
47 .it_will_return(true);
48
49 because b = () => sut.run();
50
51 public override ISaveCommand create_sut()
52 {
53 return new SaveCommand(current_project, save_as_command);
54 }
55
56 }
57}