public void OnActionExecuting_Result_returns_BadRequestObjectResult() { _systemUnderTest = new ValidateModelAttribute(); var modelStateDictionary = new ModelStateDictionary(); var actionContext = new TestActionContext(modelStateDictionary); var actionExecutingContext = new ActionExecutingContext(actionContext, new List <IFilterMetadata>(), new Dictionary <string, object>(), null); modelStateDictionary.AddModelError("name", "IsInvalid"); _systemUnderTest.OnActionExecuting(actionExecutingContext); Assert.IsAssignableFrom <BadRequestObjectResult>(actionExecutingContext.Result); }
public void OnActionExecuting_Result_is_null() { _systemUnderTest = new ValidateModelAttribute(); var modelStateDictionary = new ModelStateDictionary(); var actionContext = new TestActionContext(modelStateDictionary); var actionExecutingContext = new ActionExecutingContext(actionContext, new List <IFilterMetadata>(), new Dictionary <string, object>(), null); _systemUnderTest.OnActionExecuting(actionExecutingContext); Assert.IsNull(actionExecutingContext.Result); _systemUnderTest.OnActionExecuted(new ActionExecutedContext(actionContext, new List <IFilterMetadata>(), null)); Assert.IsNull(actionExecutingContext.Result); }
private void SetupDependencies(Exception exception) { var filters = new List <IFilterMetadata>(); _systemUnderTest = new ModelErrorOnArgumentException(); _modelStateDictionary = new ModelStateDictionary(); var actionContext = new TestActionContext(_modelStateDictionary); _exceptionContext = new ExceptionContext(actionContext, filters) { Exception = exception }; }