public void BookFormViewModel_Valid_IsValidTrue() { var results = _validator.Validate(_viewModel); results.IsValid.Should().Be(true); results.Errors.Should().BeEmpty(); }
public ActionResult CreateEdit(HForm item) { var bookFormValidator = new BookFormValidator(); if (!bookFormValidator.Validate(item.Form)) { foreach (var e in bookFormValidator.Exceptions) { ModelState.AddModelError(e.Property, e.Message); } return(View(bookService.GetBook(item.Form.Id))); } else { bookService.CreateEditBook(item.Form); return(RedirectToAction("Index")); } }