【问题标题】:Can SubSonic's SimpleRepository operate in-memory?SubSonic 的 SimpleRepository 可以在内存中运行吗?
【发布时间】:2009-08-01 02:03:47
【问题描述】:

我正在使用 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);

这一切都应该发生在内存中。

【问题讨论】:

    标签: subsonic subsonic3 simplerepository


    【解决方案1】:

    但是,您可以实现 IRepository(SimpleRepository 实现)并使用它来代替 SimpleRepo(无论如何您都应该这样做)。然后你可以根据需要模拟/伪造它。

    【讨论】:

    • 你知道是否已经有一个实现 IRepository 的 InMemoryRepository,还是我只需要构建它?看起来很简单。
    【解决方案2】:

    SimpleRepository 不支持此功能,目前只有 ActiveRecord 支持。

    http://subsonicproject.com/docs/Selecting_Templates

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多