Isolation frameworks isolate the code from their dependencies, but they do it programmatically, and without hassle. What makes Typemock Isolator 2010 different than other frameworks (like Rhino Mocks and Moq) is that you don’t need to change the tested code just to test it.
Let’s look at the test we got last time – using a fake Message Queue to test that the message was called:
[TestMethod]
public void Send_StringMessage_MessageWasSent()
{
var fakeQueue = new FakeMessageQueue();
var server = new Server();
server.SendMessage(fakeQueue, "message");
Assert.IsTrue(fakeQueue.messageWasSent);
}
We’re actually doing two things in this test with our fakeMessageQueue object. The first is changing behavior – the SendMessage method does not call the original SendMessage method. The second is testing that the method was called. We do this by using a public field in the fake object.
Read more: IUpdateable from Eric Nelson