有没有办法在这种情况下模拟dbcontext?我正在使用cqrs。
public class QueryHandler1 : IQueryHandler<Query1,string>
{
private readonly IDbInvoker invoker;
public QueryHandler1 (IDbInvoker invoker)
{
this.invoker = invoker;
}
public string Handle(Query1 query)
{
//Here I want to have my mocked context somehow.
return invoker.Invoke<MyMockedContext, string>(context =>
{
//logic which I want to test with my mocked context
});
}