public void EditTest() { School v = new School(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.SchoolCode = "ece"; v.SchoolName = "QZ8AgkqPf"; context.Set <School>().Add(v); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.Edit(v.ID.ToString()); Assert.IsInstanceOfType(rv.Model, typeof(SchoolVM)); SchoolVM vm = rv.Model as SchoolVM; v = new School(); v.ID = vm.Entity.ID; v.SchoolCode = "xLq"; v.SchoolName = "36xgZ9K7"; vm.Entity = v; vm.FC = new Dictionary <string, object>(); vm.FC.Add("Entity.SchoolCode", ""); vm.FC.Add("Entity.SchoolName", ""); _controller.Edit(vm); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <School>().FirstOrDefault(); Assert.AreEqual(data.SchoolCode, "xLq"); Assert.AreEqual(data.SchoolName, "36xgZ9K7"); Assert.AreEqual(data.UpdateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10); } }
public void EditTest() { School v = new School(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v.SchoolCode = "G15"; v.SchoolName = "I8KN8vsf2"; v.SchoolType = Ray.BiliBiliToolPro.AdminWeb.Model.SchoolTypeEnum.PUB; v.Remark = "cRS"; context.Set <School>().Add(v); context.SaveChanges(); } SchoolVM vm = _controller.Wtm.CreateVM <SchoolVM>(); var oldID = v.ID; v = new School(); v.ID = oldID; v.SchoolCode = "c4Z"; v.SchoolName = "Fw9Zg"; v.SchoolType = Ray.BiliBiliToolPro.AdminWeb.Model.SchoolTypeEnum.PRI; v.Remark = "LwU"; vm.Entity = v; vm.FC = new Dictionary <string, object>(); vm.FC.Add("Entity.SchoolCode", ""); vm.FC.Add("Entity.SchoolName", ""); vm.FC.Add("Entity.SchoolType", ""); vm.FC.Add("Entity.Remark", ""); var rv = _controller.Edit(vm); Assert.IsInstanceOfType(rv, typeof(OkObjectResult)); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data = context.Set <School>().Find(v.ID); Assert.AreEqual(data.SchoolCode, "c4Z"); Assert.AreEqual(data.SchoolName, "Fw9Zg"); Assert.AreEqual(data.SchoolType, Ray.BiliBiliToolPro.AdminWeb.Model.SchoolTypeEnum.PRI); Assert.AreEqual(data.Remark, "LwU"); Assert.AreEqual(data.UpdateBy, "user"); Assert.IsTrue(DateTime.Now.Subtract(data.UpdateTime.Value).Seconds < 10); } }