我正在尝试使用MVC 4,Moq 4和C#4.5为ConrollerContext对象模拟HttpResponse
我的代码在这里:
var context = new Mock<HttpContextBase>(); var response = new Mock<HttpResponseBase>(); context.SetupProperty(c => c.Response = response);
我尝试使用Setup().返回()和SetupGet()但我不断收到以下错误:
“Property or Indexer ‘System.Web.HttpContextBase.Response’ cannot be assigned to — it is read only.