偽のリポジトリをセットアップしようとしています。
public class FooRepo {
public FutureFoo<Foo> GetById(int id) {
var foo = new Foo();
return new FutureValue(foo);
}
public FutureQuery<Foo> GetByCategory(int categoryId) {
var foos = new[] { new Foo(), new Foo() new Foo() };
return //what goes here?
}
}
これの目的は、データベース接続に依存せずに、データに依存するテストを作成することです。FutureValue<>
直接オブジェクトを受け入れるコンストラクターを提供するため、これは型にとって非常に簡単でした。ただし、コンストラクターFutureQuery<>
は引数を取りますIQueryable query, Action loadAction
無視してもloadAction
いいですか?
そのような:new FutureQuery<Foo>(foos.AsQueryable(), () => { });
または、これについての適切な方法は何ですか?
強制解決:
(FutureQuery<Foo>) Activator.CreateInstance(typeof(FutureQuery<Foo>),
BindingFlags.NonPublic | BindingFlags.Instance, null,
new object[] { foos.AsQueryable(), null }, null);