Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // SETUP
- MockRepository mocks = new MockRepository();
- IQueue mockQueue = mocks.StrictMock<IQueue>();
- queue.Received+=null;//create an expectation that someone will subscribe to this event
- LastCall.IgnoreArguments();// we don't care who is subscribing
- IEventRaiser raiseReceivedEvent = LastCall.GetEventRaiser();//get event raiser for the last event, in this case, Received
- Expect.Call(mockQueue.Send).Return(msgId);
- mocks.ReplayAll();
- // EXEC
- Requester req = new Requester(mockQueue);
- // We expect this method to send a request to the mock queue object.
- req.DoSomething();
- // Now we raise an event from the mock queue object.
- raiseReceivedEvent.Raise(eventArgs);
- // VERIFY
- // we would probably also check some state in the Requester object
- mocks.VerifyAll();
Add Comment
Please, Sign In to add comment