public void ExecuteResultSetsContentType() { var mockHttpResponse = new Mock<HttpResponseBase>(); var mockHttpContext = new Mock<HttpContextBase>(); mockHttpContext.Setup(c => c.Response).Returns(mockHttpResponse.Object); var mockController = new Mock<Controller>(); var controllerContext = new ControllerContext(new RequestContext(mockHttpContext.Object, new RouteData()), mockController.Object); var result = new ContentResult { Content = "blah blah" }; var filterContext = new ResultExecutingContext(controllerContext, result); var filter = new ContentTypeAttribute("text/xml"); filter.OnResultExecuting(filterContext); mockHttpResponse.VerifySet(r => r.ContentType = "text/xml"); }
public void ContentTypeSetInCtor() { var attr = new ContentTypeAttribute("text/html"); Assert.AreEqual("text/html", attr.ContentType); }