public void BatchDeleteTest() { Student v1 = new Student(); Student v2 = new Student(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.Name = "Ig1N37FOm"; v1.Age = 20; v2.Name = "fQFq"; v2.Age = 92; context.Set <Student>().Add(v1); context.Set <Student>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() }); Assert.IsInstanceOfType(rv.Model, typeof(StudentBatchVM)); StudentBatchVM vm = rv.Model as StudentBatchVM; vm.Ids = new string[] { v1.ID.ToString(), v2.ID.ToString() }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { var data1 = context.Set <Student>().Find(v1.ID); var data2 = context.Set <Student>().Find(v2.ID); Assert.AreEqual(data1, null); Assert.AreEqual(data2, null); } }
public void BatchDeleteTest() { Student v1 = new Student(); Student v2 = new Student(); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { v1.Name = "zKk"; v2.Name = "qXR"; context.Set <Student>().Add(v1); context.Set <Student>().Add(v2); context.SaveChanges(); } PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new Guid[] { v1.ID, v2.ID }); Assert.IsInstanceOfType(rv.Model, typeof(StudentBatchVM)); StudentBatchVM vm = rv.Model as StudentBatchVM; vm.Ids = new Guid[] { v1.ID, v2.ID }; _controller.DoBatchDelete(vm, null); using (var context = new DataContext(_seed, DBTypeEnum.Memory)) { Assert.AreEqual(context.Set <Student>().Count(), 0); } }