예제 #1
0
        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);


        }
예제 #2
0
        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);


        }