Question

I'm thinking of using the Simple.Data package (https://github.com/markrendle/Simple.Data) and thought of an interesting issue in terms of implementation.

Simple.Data appears to be designed abstract away a lot of the need to implement your own data layer through providing a dynamic object, so you could do something like:

var user = Database.Open().Users.FindById(id);

....which is great. However I usually develop something like a generic repository with an interface to allow me to stub the data layer in unit tests and remain flexible for swapping my data layer out in future.

If anyone has used Simple.Data - what are your thoughts on using a repository pattern with it? Is it unnecessary? Have you had any experience replacing the dependency upon the Database object when unit testing with Simple.Data?

Any feedback would be appreciated!

p.s. I'm not talking about unit testing data retrieval itself using Simple.Data as covered here - http://simplefx.org/simpledata/docs/pages/Test/Basics.htm - more about replacing the dependency on simple data when unit testing my business layer for example, something a repository pattern could help achieve

Was it helpful?

Solution

You might find this blog post I wrote about using Impromptu-Interface with Simple.Data helps your decision. Effectively, you can declare the interfaces for your repository layer and Simple.Data will implement them automagically.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top