After reading this Testability and Entity Framework 4.0
article about 75 times yesterday, it is not clear to me what the author was trying to say. He seems to indicate that UoW and Repository patterns are two different patterns to use to solve similar problems. In other words, UoW was more for multi objects that need to be orchestrated prior to commit, whereas Repository is for more straightforward persistence.
When I do more searching online to find the holy grail framework to allow me to unit test my application, I see more articles that seem to imply that UoW is part of the Repository pattern, or vice versa.
Which interpretation is correct?
At the end of the day I want to be able to isolate my application enough to allow mocking of the data to in memory objects.
You can use them both separately or together.
These posts that you cant use in memory objects – well – some would highly disagree without seeing a specific failing case.
Repository pattern dictates generally loading information – and if you so choose – saving information.
From MSDN: “Use a repository to separate the logic that retrieves the data and maps it to the entity model from the business logic that acts on the model. T”
Load your data from your repository. Your unit of work pattern can surely encapsulate a transaction around all of your repository saves.
There is no reason you cannot use one, the other, or both together.
Now – testing your objects depends on WHAT you want to test. IF you are testing a save to a store – then sure – this isn’t a unit test. IF you want to mock your store and simply return an in memory object, then so be it. I think I’m missing why there is concern here from the other posters – call me blissfully ignorant.
Your unit tests are supposed to test a ‘unit’ not some potential call your app may or may not make. You want to test for ex. a method – not a linq provider