public void ModelValidateTestFalse() { var model = new MessageModel(); model.UpdateDate = DateTime.Now.AddDays(-1); model.Title = "title"; model.Body = "body"; TestContextController controller = new TestContextController(); var result = controller.TestTryValidateModel(model); Assert.IsFalse(result); var state = controller.ModelState; Assert.IsFalse(state.IsValid); }
public void ModelValidateTestOk() { var model = new MessageModel(); model.UpdateDate = DateTime.Now.AddDays(1); model.Title = "title"; model.Body = "body"; model.Weight = (decimal) 1; model.WeightDouble = (decimal?) 2.12; TestContextController controller = new TestContextController(); var result = controller.TestTryValidateModel(model); Assert.IsTrue(result); var state = controller.ModelState; Assert.IsTrue(state.IsValid); }