So you want unit testing – Good idea. FakeItEasy is an easy but still powerfull way to do unit testing.

Below is listed sample code to get started doing unit test with FalkeItEasy.

Now we just need an implementation of ICalculator (the one we want to test)

The implementation of ICalculator takes an ILog as parameter to the constructor. We now want to assure the calculator uses the logger correctly.
In case of an error (e.g. division by zero) the Log.Error method shall be called. In other cases we just want to assure the Log.Info has been called.

The HandleEvents() test method quickly demonstrate how to raise an event and assert.

Go ahead and do some Unit testing – no excuses.