How do you mock adding items to a repository or DbContext using moq?

前端 未结 5 1141
猫巷女王i
猫巷女王i 2021-01-23 17:00

The examples I\'ve seen for using moq for a repository only show how to mock things being returned. I have a somewhat strange requirement: when a query is executed, if a conditi

5条回答
  •  时光取名叫无心
    2021-01-23 17:12

    This blog article might be of use, although my design has changed somewhat since I wrote the post and I really need to update it. I used teh generic repository pattern in a way that enables the DbContext to be mocked. This allows the data access layer to be tested 'right up to the edges'. Generic Repository and Unit of Work

提交回复
热议问题