public void HttpActionContextWrapper() { var uri = "http://google.com/"; var userAgent1 = "user_agent_1"; var userAgent2 = "user_agent_2"; var requestMessage = new HttpRequestMessage(HttpMethod.Get, uri); requestMessage.Headers.UserAgent.ParseAdd(userAgent1); requestMessage.Headers.UserAgent.ParseAdd(userAgent2); var responseMessage = new HttpResponseMessage(HttpStatusCode.OK); var controllerContext = new HttpControllerContext(); controllerContext.Request = requestMessage; var actionContext = new HttpActionContext(); actionContext.ControllerContext = controllerContext; actionContext.Response = responseMessage; var wrapper = new HttpActionContextWrapper(actionContext); Assert.Equal(HttpMethod.Get.Method, wrapper.GetHttpMethod()); Assert.Equal(uri, wrapper.GetUri()); Assert.Contains(userAgent1, wrapper.GetUserAgent()); Assert.Contains(userAgent2, wrapper.GetUserAgent()); Assert.Equal((int)HttpStatusCode.OK, wrapper.GetStatusCode()); }
public void HttpActionContextWrapper_NullHttpActionContext() { var wrapper = new HttpActionContextWrapper(null); Assert.Null(wrapper.GetHttpMethod()); Assert.Null(wrapper.GetUri()); Assert.Null(wrapper.GetUserAgent()); }