Monthly Archives: April 2015

FakeItEasy and Partial Mocking

There are many situations where you want to partially mock the class. You typically want to change the behavior of a single method in a class having many methods. So what you do is partial mocking. FakeItEasy and Partial Mocking go very well together.

FakeItEasy and a case of method configuration

Recently while writing unit tests for a device driver I came across a situation. I had to simulate the call to the device to wait for sometime and then throw an error and then check if I handled it properly. This helped. This configures the Start method (which in real life issues command to the… Read More »

FakeItEasy and Protected methods

I often find myself dealing with protected methods in the unit testing land. Now if the method is public then this works

However when the method is protected then it does not fly. With FakeItEasy you have to take the different approach. A.CallTo(fakeObject).Where(x => x.Method.Name ==”MethodUnderTest”).MustHaveHappened(); And needless to say, the method under test… Read More »