I have service classes based on Entity Framework 4. I’d like to test them on a database filled with pre-generated sample data. The problem is: I would like the tests, whether passed or failed, to not actually touch the database, so that it may be re-used for other tests.
Thus I’d like ObjectContext.SaveChanges to pretend that everything’s fine, and keep the changes in memory, but silently omit their actual persistence in the data source. Is this possible?
P.S. I am aware of the repository pattern, but would not like to use it in this case.
I am going to go out on a limb here with this one… I know that it works with linq-to-sql
You can override the savechanges method in your context/container
and actually remove the base.SaveChanges();
It looks like this:
so if you uncomment this line, you can adapt it to your situation