SubSonic的SimpleRepository可以在内存中操作吗?

3

我正在使用Subsonic的SimpleRepository,我正在尝试编写一些单元测试,以便它们不会触及数据库,但我很难确定SimpleRepository是否可以针对内存列表(例如活动记录)而不是实际数据库进行工作。

我想要做以下事情:

//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);

这些操作都应该在内存中完成。

2个回答

2

然而,你可以实现IRepository(SimpleRepository已经实现了它),并使用它代替SimpleRepo(你应该这样做)。这样,你就可以根据需要进行模拟/伪造。


1
你知道是否已经有一个实现了IRepository的InMemoryRepository,还是我需要自己构建它?看起来很简单。 - Lance Fisher

0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接