Exemplo n.º 1
0
        public void CaughtValidationExceptionHook()
        {
            ValidationFailureModel model = new ValidationFailureModel();
            var result = model.Process(Request);

            Assert.IsTrue(result != null && result.Response != null && result.Status != null);
            Assert.IsTrue(result.Response is bool r && !r && result.Status == HttpStatusCode.BadRequest);
        }
Exemplo n.º 2
0
        public void CaughtModelStateValidationExceptionHook()
        {
            ModelStateDictionary modelState = new ModelStateDictionary();

            modelState.AddModelError("RandomProperty", "has invalid characters.");

            ValidationFailureModel model = new ValidationFailureModel();
            var result = model.Process(Request, modelState);

            Assert.IsTrue(result != null && result.Response != null && result.Status != null);
            Assert.IsTrue(result.Response is bool r && !r && result.Status == HttpStatusCode.BadRequest);
        }