Guest User

Untitled

a guest
Jun 18th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. // SETUP
  2. MockRepository mocks = new MockRepository();
  3. IQueue mockQueue = mocks.StrictMock<IQueue>();
  4.  
  5. queue.Received+=null;//create an expectation that someone will subscribe to this event
  6. LastCall.IgnoreArguments();// we don't care who is subscribing
  7. IEventRaiser raiseReceivedEvent = LastCall.GetEventRaiser();//get event raiser for the last event, in this case, Received
  8. Expect.Call(mockQueue.Send).Return(msgId);
  9. mocks.ReplayAll();
  10.  
  11. // EXEC
  12. Requester req = new Requester(mockQueue);
  13.  
  14. // We expect this method to send a request to the mock queue object.
  15. req.DoSomething();
  16. // Now we raise an event from the mock queue object.
  17. raiseReceivedEvent.Raise(eventArgs);
  18.  
  19. // VERIFY
  20. // we would probably also check some state in the Requester object
  21. mocks.VerifyAll();
Add Comment
Please, Sign In to add comment