Mocking DbEntityEntry

安稳与你 提交于 2019-12-06 00:17:57

And what is the point of unit testing this code? You fake the Find method, then you fake DbEntityEntry and there will be no real logic to test.

Anyway EF code is not unit testable in general. That is one reason why people believe that repository will help them because they mock / fake their repository when testing upper layer. Repository is then tested with integration tests to make sure that everything in EF and database works as expected.

You will not fake DbEntityEntry with Moq. Maybe with TypeMock Isolator or MS Fakes you will be able to do more but it is not needed in your sample code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!