Tag Archives: Unit testing

Faking Getters and Setters of Properties

By | May 19, 2016

This post on Faking Getters and Setters of Properties using FakeItEasy will help you to configure the behavior of the properties of the objects you fake. This is not as apparent as the various techniques on configuring the behavior of the methods of the faked objects. Getters and Setters are as configurable as regular methods… Read More »

Faking hardware using FakeItEasy

By | March 22, 2016

This post on Faking hardware using FakeItEasy is based on a simple premise. You should not suffer just because the function you are unit testing invokes some hardware. Writing hardware/device simulators used to be the way out. But with FakeItEasy, it is easy to fake your way out of this. So Let us see how… Read More »

Test builder pattern using fluent interface

By | November 23, 2015

This is a brief c# based tutorial on test builder pattern using fluent interface. It is one of the many ways we can tackle the problem of brittle tests. I will try to keep the example as real world as possible. As usual I will deal with the WHY before the HOW.

FakeItEasy and verifying method parameters

By | May 16, 2015

How about checking if the method was called with right parameters as a part of your unit tests ? You can do it in many ways. Using FakeItEasy, it is easy to verify that the expected parameters were used to make the function call.

FakeItEasy and a case of method configuration

By | April 24, 2015

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

By | April 24, 2015

I often find myself dealing with protected methods in the unit testing land. Now if the method is public then this works A.CallTo(() => fakeObject.MethodUnderTest()).MustHaveHappened(); 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… Read More »