1

Closed

Presenter Cancels But Does Not Raise Event

description

I had a strange issue where I was validating a save via the OnBeforeSave method and manually setting e.Cancel to false. This, as I expected, cancelled the SaveCore() method, but it did not raise the SaveCancelled event. I studied the source code and noted that for exceptions and invalid (IsValid = false) views the SaveCancelled event is raised.
 
Steps to create a failing test to see the issue:
 
1) add a handler to the presenter's OnBeforeSave event.
2) Inside the handler method, change e.Cancel to "true".
3) add a handler to the presenter's OnSaveCancelled event.
4) Inside this handler, simply set a SaveCancelledEventRaised flag to true.
5) override SaveCore() with whatever. Just make sure it will not throw an exception.
6) Set the SaveCancelledEventRaised flag to false.
7) call the presenter.Save() method
8) Assert that the SaveCancelledEventRaised flag is true;
 
 
Suggested solutions:
 
a) Specify or make clear that only exceptions and an invalid view cause the SaveCancelled event to be raised.
 
b) (this one makes more sense to me) allow the change of e.Cancel to true to cause the SaveCancelled event to be raised.
Closed Feb 15, 2007 at 7:40 PM by Heynemann

comments

wrote Feb 15, 2007 at 7:40 PM

Resolved with changeset 18470.

wrote Feb 13, 2013 at 12:04 AM

wrote May 15, 2013 at 4:06 AM