@Kumquat
This can be a bit frustrating to work through the first time. There
are two basic event tests I like to use:
1) test the event is registered (wired, routed, attached) correctly
2) invoke the event and test expected behavior
Here's how I might do test number 1 (in C#, sorry - I don't do VB)
[Test]
public void
ClearClickedEvent_InstantiatingTheController_RegistersEventToViewClearClicked
()
{
// ARRANGE - set up a mock of your view
var view = MockRepository.GenerateMock<IClientSearchView>();
// ACT - make a new controller
var c = new Controller(...)
// ASSERT - this is all you need to do
view.AssertWasCalled(x => x.ClearClicked += c.ViewClearClicked );
}
Test 2 is more involved and likely be more than one test, but the main
idea is to use the event raiser to raise your event, ie:
view.Raise(x => x.ClearClicked += null, this,
EventArgs.Empty); // EventArgs need not be EventArgs.Empty
and then assert a call was made that verifies the behavior you expect.
Hope that helps.
Berryl