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.