Category Archives: Moq

How to mock lazy initialization of objects in C# unit tests using Moq

I was unable to find it clearly documented how to use Moq with objects that are to be lazy initialized, so below are the steps I took to do so. Here is my class under test: public class MyClass { … Continue reading

Posted in C#, Moq | Tagged , | 2 Comments

Unit Test Stubs – Returning different values on consecutive calls

I have been learning C# these past few months.  The other day I had to write a unit test in C# that would return different results on consecutive calls from a mocked method where the inputs were the same.  With … Continue reading

Posted in C#, Moq | Tagged , | Leave a comment