public void BatchDeleteTest() { Patient v1 = new Patient(); Patient v2 = new Patient(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.ID = 92; v1.IdNumber = "9hTGN"; v1.PhotoId = AddPhoto(); v2.IdNumber = "Cknil"; v2.PhotoId = v1.PhotoId; context.Set <Patient>().Add(v1); context.Set <Patient>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(PatientBatchVM)); PatientBatchVM vm = rv.Model as PatientBatchVM; vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <Patient>().Count(), 2); } }
public void BatchDeleteTest() { Patient v1 = new Patient(); Patient v2 = new Patient(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.ID = 55; v1.PatientName = "YwcJC"; v1.IdNumber = "HxDBfg9Ar"; v2.PatientName = "sH3P"; v2.IdNumber = "BlwN4UFY"; context.Set <Patient>().Add(v1); context.Set <Patient>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(PatientBatchVM)); PatientBatchVM vm = rv.Model as PatientBatchVM; vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <Patient>().Count(), 2); } }