Using Moq callbacks as Verify

Posted by & filed under Unit testing.

One thing using Moq always bugged me. When needing to verify some method call, Moq provides a Verify-metod on the Mock object: So, what’s wrong with this piece of code? In fact nothing (if you ask me). The “problem” is the error message if the test fails: Something fails! Moq is in fact pretty decent… Read more »

Unit-testing HtmlHelper extension methods

Posted by & filed under Unit testing.

I sometimes find myself doing extension methods for the HtmlHelper class in ASP.NET MVC. I like HtmlHelper, but I don’t really dig when the methods generate HTML. This is what partial views are for, right? I usually add small utility methods related to a single view on the view model, but when dealing with shared… Read more »

Essential c# unit testing tools

Posted by & filed under Unit testing.

During the last 6 years, I’ve preached unit testing to my colleagues and people attending my test-driven development courses. The set of tools I’ve used for this purpose have been stable, for the most part. This blog post is an attempt to create a snapshot of the tools and frameworks I’m using right now. Unit-Test… Read more »

Using AutoMoqCustomization with NUnit, Moq and AutoFixture

Posted by & filed under Unit testing.

I’ve used mock as long as I remember (pretty much). I’m a big fan of the whole dependency injection movement and make heavily use of IoC containers. Especially constructor injection turns out to be the correct approach for almost every system I’ve worked on. One thing that always bugged me is when creating a new object to run… Read more »