I am trying to mock httpContext
using Moq framework
to esnure that httContext.Current is not null
when request comes from Unit test but couldn't really make it working.
After doing google, i came with following steps so for and not sure what steps are next before i make post call to Api controller
.
step 1
Add Moq package to project
step 2
using Moq;
step 3
var context = new Mock<HttpContextBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
request.Setup(r => r.UrlReferrer).Returns(new Uri("http://ift.tt/29lLFsT"));
response.Setup(r => r.Cookies).Returns(new HttpCookieCollection());
context.Setup(c => c.Request).Returns(request.Object);
context.Setup(c => c.Response).Returns(response.Object);
Can someone help me out for the next steps i need to do before making Post controller request.
Aucun commentaire:
Enregistrer un commentaire