I have the following senario. And I am using RhinoMock 3.0.5 as
mocking framework since I am using .net 2.0. ( I am not using .net 3.0
yet)
Public interface IView {
void RegisterChangeRequestListener<T>(String eventName,
EventHandler<ChangeRequestEventArgs<T>> handler);
void UnRegisterChangeRequestListener<T>(String eventName,
EventHandler<ChangeRequestEventArgs<T>> handler);
}
public class Controller {
IModel model;
IView view;
public Controller(IModel model, IView view)
{
Initialize(model, view);
}
public void Initialize(IModel model, IView view)
{
this.model = model;
this.view = view;
WireEvents();
}
protected override void WireEvents()
{
View.RegisterChangeRequestListener<bool>(
Constants.EVENT_REFRESH_VIEW, ViewEvent_RefreshView);
View.RegisterChangeRequestListener<bool>(
Constants.EVENT_CANCEL_REQUEST, ViewEvent_CancelRequest);
}
protected void ViewEvent_RefreshView(object sender,
ChangeRequestEventArgs<bool> e)
{
// Do something here
}
protected void ViewEvent_ CancelRequest (object sender,
ChangeRequestEventArgs<bool> e)
{
// Do something here
}
}
I am trying to unit test all the events are wired up properly.
[Test]
public void Should_hook_up_to_events_when_controller_is_created
()
{
using (mockFramework.Record())
{
// Verify that all events are registered
Expect.Call(delegate
{
mockView.RegisterChangeRequestListener<bool>(
Constants.EVENT_REFRESH_VIEW, ?? );
});
Expect.Call(delegate
{
mockView.RegisterChangeRequestListener<bool>(
Constants. EVENT_CANCEL_REQUEST, ??);
});
}
using (mockFramework.Playback())
{
Controller SUT = new Controller(mockModel,
mockLoader);
}
}
How can I pass in the handlers to Expect.call so that I can test the
right methods are hooked?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en
-~----------~----~----~----~------~----~------~--~---