I have read this article: https://www.gaui.is/how-to-mock-the-datacontext-linq/Since this article is almost 4 years old I have no hope that in article's comments my question will be answered so I decided to ask it here.In this article author creates another MockRepository and MockUnitOfWork classes and implements their own methods to match Repository and UnitOfWork methods. but uses List instead of DataContext.If I use this approach, and in future I will change my implementation for Repository or UnitOfWork. It means that I have to change Implementation for MockRepository and MockUnitOfWork too. It seems a bit frustarting for me. It looks like I am testing MockRepository and MockUnitOfWork separately and Repository and UnitOfWork still stays untested.How do you think?
Should I mock Repository and Unit Of Work for Unit Testing?
unit testing;repository;mocking;unit of work
If you follow the pattern described in the article, then you would only need to change MockRepository or MockUnitOfWork if the respective interface (IRepository and IUnitOfWork) changes.The idea behind this is that you can unit-test all the other parts of your application without needing access to a real database (and without the trouble that data persistence in a proper database gives you while testing).Only the Repository and UnitOfWork classes themselves (the ones that contain the actual database connection) would need a real database to be unit-tested and if their implementation is simple enough, you can even choose to defer testing of those classes till the integration or end-to-end tests.