In the last couple of weeks I had a chance to sprinkle some of JP’s syntactic sugar, all over my projects. It’s amazing how much more concise my units test have become. I’ve had a couple of issues where I was mocking out the behavior of some Win Forms controls, but for the most part it’s been an awesome experience!

I just wanted to take a moment to say Thank you JP! I am enjoying using your BDD (on steroids) extensions. If you haven’t already you need to check it out here. NOW!

Maaad, maaaad props Mr. JP!

public class behaves_like_save_changes_view_bound_to_presenter : concerns_for<SaveChangesView>    
  {    
    context c = () => { presenter = an<ISaveChangesPresenter>(); };    
    because b = () => sut.attach_to(presenter);    

    static protected ISaveChangesPresenter presenter;    
  }    
    
  public class when_the_save_button_is_clicked : behaves_like_save_changes_view_bound_to_presenter    
  {
    it should_forward_the_call_to_the_presenter = () => presenter.was_told_to(x => x.save());    

    because b = () => EventTrigger.trigger_event<Events.ControlEvents>( new EventArgs()), sut.ux_save_button);
  }
    
  public class when_the_cancel_button_is_clicked : behaves_like_save_changes_view_bound_to_presenter    
  {    
    it should_forward_the_call_to_the_presenter = () => presenter.was_told_to(x => x.cancel());

    because b = () => EventTrigger.trigger_event<Events.ControlEvents>(x => x.OnClick(new EventArgs()),sut.ux_cancel_button);    
  }    

  public class when_the_do_not_save_button_is_clicked : behaves_like_save_changes_view_bound_to_presenter    
  {
    it should_forward_the_call_to_the_presenter = () => presenter.was_told_to(x => x.dont_save());

    because b = () => EventTrigger.trigger_event<Events.ControlEvents>( x => x.OnClick(new EventArgs()), sut.ux_do_not_save_button );
  }
comments powered by Disqus