public void OnActionExecuting_CustomProductModelValidationActionFilter_ResponseIsSetToBadRequest() { var actionContext = new HttpActionContext(); actionContext.ModelState.AddModelError("Name", "Error"); actionContext.ControllerContext = new HttpControllerContext(); actionContext.ControllerContext.Request = new HttpRequestMessage(); var attribute = new Attributes.ProductModelValidationFilter() { TestRequestMessage = new HttpRequestMessage() }; attribute.OnActionExecuting(actionContext); Assert.AreEqual(HttpStatusCode.BadRequest, actionContext.Response.StatusCode); }
public void OnActionExecuting_CustomProductModelValidationActionFilter_ResponseIsNotSet() { var actionContext = new HttpActionContext(); actionContext.ControllerContext = new HttpControllerContext(); actionContext.ControllerContext.Request = new HttpRequestMessage(); actionContext.ModelState.Clear(); var attribute = new Attributes.ProductModelValidationFilter { TestRequestMessage = new HttpRequestMessage() }; attribute.OnActionExecuting(actionContext); Assert.IsNull(actionContext.Response); }