public void CreateTest() { PartialViewResult rv = (PartialViewResult)_controller.Create(); Assert.IsInstanceOfType(rv.Model, typeof(SchoolVM)); SchoolVM vm = rv.Model as SchoolVM; School v = new School(); v.SchoolCode = "ece"; v.SchoolName = "QZ8AgkqPf"; vm.Entity = v; _controller.Create(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <School>().FirstOrDefault(); Assert.AreEqual(data.SchoolCode, "ece"); Assert.AreEqual(data.SchoolName, "QZ8AgkqPf"); Assert.AreEqual(data.CreateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.CreateTime.Value).Seconds < 10); } }