I am trying to mock an HttpResponse for a ConrollerContext object using MVC 4, Moq 4 and C # 4.5
My code is here:
var context = new Mock<HttpContextBase>();
var response = new Mock<HttpResponseBase>();
context.SetupProperty(c => c.Response = response);
I tried using Setup().Returns()and SetupGet(), but I keep getting the following error:
'The property or index element' System.Web.HttpContextBase.Response 'cannot be assigned - it is read-only.
I tried Google and searched this site, but I can not find the answer.
source
share