我正在对我的 API 服务进行单元测试,并且使用 MockRquestContext 一切正常。对 this.GetSession() 的调用总是返回一个 IAuthSession,但我有一个自定义的 AuthUserSession,据我所知,没有办法创建我的自定义 AuthUserSession 的实例并将其添加到模拟上下文中。这可能吗?
var service = container.Resolve<AgencyCaseService>();
service.SetResolver(new BasicResolver(container));
var context = new MockRequestContext() { ResponseContentType = ContentType.Json };
//Something like this
MyCustomAuthSession session = new MyCustomAuthSession() { set some values}
context.AuthSession = session//this doesn't exist but it's the type of thing i need to do
service.RequestContext = context;