When you start to get serious about testing your website, following SOLID prinicples and dependency injection, you'll likely end up using Moq, the best free mocking framework for .NET. In this section, I'll cover everything you need to get up and running with Moq.
Moq is a great framework that allows you to unit test part of your application that wouldn't otherwise be possible. As we work with Microsoft, you might have code that's reliant on the HttpContext, or an SMTP provider to work. When you run tests yo[...]
When you're aiming for high test coverage in your website, you'll inevitably need to test things like service locators, the HTTP context, controllers, base class and a host of other weird and wonderful classes. In today's tutorial, I'm going to quic[...]
When we write tests and we're using dependency injection, we sometimes want to test that a certain method was called (or in some instances NOT called). Moq makes this really easy with its Verify() method.
How To Use Moq To Make Sure A Method Gets[...]
I recently needed to test a method that took in a string and a list of integers, and then return a matching object the input ID matched the ID in the database. After a quick Google, I couldn't find how to do this easily, so here it's a quick code ex[...]
Often when we want to write unit tests, we need to work with third-party code which we can't change. Moq is a great free library, but it sadly can't mock non-virtual methods or properties. This can be a pain but, usefully, it is fixable. I think in[...]