views:

199

answers:

2

I'm working with Subsonic's SimpleRepository, and I'm trying to write some unit tests so they don't touch the database, but I'm having trouble figuring out if SimpleRepository can work against in-memory lists (Like the active record can) instead of an actual database.

I would like to do the following:

//setup test data
var repo=new SimpleRepository();
var key=repo.Add(new Post {Title = "Test Title", Author = "Test Author"});

//later, a the following would be called and should return the post
var post = repo.Single<Post>(key);

This should all happen in memory.

A: 

SimpleRepository doesn't support this feature currently only ActiveRecord does.

http://subsonicproject.com/docs/Selecting_Templates

Adam
+2  A: 

You can, however, implement IRepository (which SimpleRepository implements) and use it instead of the SimpleRepo (which you should do anyway). Then you can mock it/fake it as needed.

Rob Conery
Do you know if there is already an InMemoryRepository that implements IRepository out there, or do I just need to build this? Looks simple enough.
Lance Fisher
Not quite as simple as I thought at first...
Lance Fisher