cat bdd-on-creatine.md

BDD on Creatine

Mar 12, 2009

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.

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.

  public class when_prompted_to_save_changes_to_the_project : concerns_for<SaveChangesView>
  {
    context c = () =>
    {
      presenter = an<ISaveChangesPresenter>();
    };

    after_the_sut_has_been_created after = () =>
    {
      save_changes_window = sut;
      save_changes_window.attach_to(presenter);
    };

    protected static ISaveChangesPresenter presenter;
    protected static SaveChangesView save_changes_window;
  }

  public class when_the_save_button_is_pressed : when_prompted_to_save_changes_to_the_project
  {
    it should_save_the_current_project = () =>
    {
      presenter.was_told_to(x => x.save());
    };

    because b = () =>
    {
      save_changes_window.save_button.control_is(x => x.OnClick( new  EventArgs()));
    };
  }

  public class when_the_cancel_button_is_pressed : when_prompted_to_save_changes_to_the_project
  {
    it should_not_continue_processing_the_previous_action = () =>
    {
      presenter.was_told_to(x => x.cancel());
    };

    because b = () =>
    {
      save_changes_window.cancel_button.control_is(x => x.OnClick( new  EventArgs()));
    };
  }

  public class when_the_do_not_save_button_is_pressed : when_prompted_to_save_changes_to_the_project
  {
    it should_not_save_the_project = () =>
    {
      presenter.was_told_to(x => x.dont_save());
    };

    because b = () =>
    {
      save_changes_window.do_not_save_button.control_is(x => x.OnClick( new  EventArgs()));
    };
  }

I hope this is slightly more soluble, then my previous post.