I am doing a TDD project using EF. I want to unit test the insertion operations I make. How should I do that?
What I have in mind;
-
In the unit test, I can query the database if my insertion was successful.
-
I can depend on other methods on my business library to check back if the insertion was successful, but I think that violates the purpose of the UNIT testing.
What are your suggestions?
Or should I use a mock framework, like Moq?
This is really integration testing not unit testing, normally with TDD i test to the boundries of my system, ie to the up to but not including the component which actually calls the external system. An example of this method can be found here: http://dl.dropbox.com/u/37129059/StaticVoid.Repository.Demo.zip using my repository framework (http://blog.staticvoid.co.nz/2011/10/staticvoid-repository-pattern-nuget.html).
Having said this its also valuable to do integration testing, especially on larger projects, whether this is via automated UI testing or some other means.