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

前端 未结 5 1139
猫巷女王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:25

    You would not mock the repository; you would have an alternate repository that would use an in-memory store instead of the database, then use IoC to select the correct repository implementation for tests/code.

提交回复
热议问题