Are you looking for a way to write unit tests in which the system under test believes that it accepts events from a queue, but do not want to use a real queue during tests?
Check out Rhino Mocks . It allows you to create a mock version of your queue interface, and then raise events from it during the test. Some pseudo-code for checking the Requester.DoSomething () method might look like this:
MockRepository mocks = new MockRepository();
IQueue mockQueue = mocks.StrictMock<IQueue>();
queue.Received+=null;
LastCall.IgnoreArguments();
IEventRaiser raiseReceivedEvent = LastCall.GetEventRaiser();
Expect.Call(mockQueue.Send).Return(msgId);
mocks.ReplayAll();
Requester req = new Requester(mockQueue);
req.DoSomething();
raiseReceivedEvent.Raise(eventArgs);
mocks.VerifyAll();
Check out the Rhino mocks wiki for all the details.
source
share