In an attempt to further understand BDD, I chose to revise the code from my previous post after receiving some amazing advice from two people I regard highly (Scott & JP). I should state that this is my interpretation of that advice. This may or may not be the direction they were trying to guide me towards.
1 public class when_prompted_to_save_changes_to_the_project : concerns_for<SaveChangesView>
2 {
3 context c = () => { presenter = an<ISaveChangesPresenter>(); };
4
5 after_the_sut_has_been_created after = () =>
6 {
7 save_changes_window = sut;
8 save_changes_window.attach_to(presenter);
9 };
10
11 protected static ISaveChangesPresenter presenter;
12 protected static SaveChangesView save_changes_window;
13 }
14
15 public class when_the_save_button_is_pressed : when_prompted_to_save_changes_to_the_project
16 {
17 it should_save_the_current_project = () => presenter.was_told_to(x => x.save());
18
19 because b = () => save_changes_window.save_button.control_is(x => x.OnClick( new EventArgs()));
20 }
21
22 public class when_the_cancel_button_is_pressed : when_prompted_to_save_changes_to_the_project
23 {
24 it should_not_continue_processing_the_previous_action = () => presenter.was_told_to(x => x.cancel());
25
26 because b = () => save_changes_window.cancel_button.control_is(x => x.OnClick( new EventArgs()));
27 }
28
29 public class when_the_do_not_save_button_is_pressed : when_prompted_to_save_changes_to_the_project
30 {
31 it should_not_save_the_project = () => presenter.was_told_to(x => x.dont_save());
32
33 because b = () => save_changes_window.do_not_save_button.control_is(x => x.OnClick( new EventArgs()));
34 }
I hope this is slightly more soluble, then my previous post.