我无法对包含HttpContext.Current.Request.LogonUserIdentity.Name
的函数进行单元测试。
出现错误的原因是LogonUserIdentity
为空。
为了解决这个问题,我在我的单元测试中添加了以下代码以为HttpContext.Current
设置一个值:
HttpContext.Current = new HttpContext(
new HttpRequest("", "http://localhost:8609", ""),
new HttpResponse(new StringWriter())
);
我该如何为
LogonUserIdentity
赋值,以便测试我的函数?