Tag Archives: mock

Moq: how to VerifySet with an object that respects a condition

Sometimes you want to test that a service method sets up the correct object on another (singleton) service. For example, that an authentication service sets up a user object with the correct username to the app’s user context. With Moq you … Continue reading

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

Mocking Entity Framework to unit test your data services

It’s not easy to write unit tests for services that use DbContext and DbSet<T> classes from Entity Framework (or Entity Framework Core), and there are complex solutions to approach this, like separating the data access layer completely, as I propose in my UnitOfWork-EntityFramework implementation. … Continue reading

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