Unit Testing using Fakes for HttpActionContext objects

Posted by Mahendrabasutkar under ASP.NET Web API on 4/30/2018 | Points: 10 | Views : 330 | Status : [Member] | Replies : 0
I have a Attribute which has the below property set.

actionContext.Request.Properties["isActiveUser"] = true
where actionContext is HttpActionContext actionContext

How do i carry out unit testing using fakes for the same
as using below code HttpRequestMessage() thows error
the type or namespace name 'httprequestmessage' could not be found.

HttpActionContext context = new HttpActionContext();
var headerValue = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", "bzUwkDal=");
var request = new System.Net.Http.HttpRequestMessage();
request.Headers.Authorization = headerValue;
var controllerContext = new HttpControllerContext();
controllerContext.Request = request;
context.ControllerContext = controllerContext;
context.Request.Properties["isActiveUser"] = false;


(No response found.)

Login to post response