I am trying to use Rhino Mocks EventRaiser to trigger a public event
on a mocked instance of ISerialController called ReadWrite:
[TestMethod]
public void HandleReadEventOnMock()
{
MockRepository repository = new MockRepository();
ISerialController serialController =
repository.DynamicMock<ISerialController>();
var fired = false;
IEventRaiser serialStubEventRaiser = EventRaiser.Create
(serialController, "ReadWrite");
serialController.ReadWrite += delegate(object sender,
EventArgs e, string message)
{
fired = true;
};
serialStubEventRaiser.Raise(serialController, new EventArgs
());
Assert.IsTrue(fired);
}
ISerialController is really an interface extraction from the
SerialPort which is really what I am trying to fake here.
When the test runs, I get the following excpetion when the highlighted
code above runs:
TestCase
'TDDEventHandling.SerialControllerTests.HandleReadEventOnMock'
failed: System.InvalidOperationException: You have called the event
raiser with the wrong number of parameters. Expected 3 but was 2
at Rhino.Mocks.Impl.EventRaiser.AssertMatchingParameters
(MethodInfo method, Object[] args)
at Rhino.Mocks.Impl.EventRaiser.Raise(Object[] args)
at Rhino.Mocks.Impl.EventRaiser.Raise(Object sender, EventArgs
e)
C:\Appdev\TDDEventHandling\TDDEventHandling\TDDEventHandling
\SerialControllerTests.cs(291,0): at
TDDEventHandling.SerialControllerTests.HandleReadEventOnMock()
0 passed, 1 failed, 0 skipped, took 43.75 seconds.
Can you please shed any light on what I am missing? Also, is there a
better way to trigger the DataRecieved event on the SerialPort class?
Thanks very much.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---