コード例 #1
0
        public void BatchDeleteTest()
        {
            School v1 = new School();
            School v2 = new School();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.SchoolCode = "ece";
                v1.SchoolName = "QZ8AgkqPf";
                v2.SchoolCode = "xLq";
                v2.SchoolName = "36xgZ9K7";
                context.Set <School>().Add(v1);
                context.Set <School>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new string[] { v1.ID.ToString(), v2.ID.ToString() });

            Assert.IsInstanceOfType(rv.Model, typeof(SchoolBatchVM));

            SchoolBatchVM vm = rv.Model as SchoolBatchVM;

            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 <School>().Count(), 0);
            }
        }
コード例 #2
0
        public void BatchDeleteTest()
        {
            School v1 = new School();
            School v2 = new School();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.SchoolCode = "p6k";
                v1.SchoolName = "ko5Ms";
                v2.SchoolCode = "YuH";
                v2.SchoolName = "TuRmzGxE";
                context.Set <School>().Add(v1);
                context.Set <School>().Add(v2);
                context.SaveChanges();
            }

            PartialViewResult rv = (PartialViewResult)_controller.BatchDelete(new Guid[] { v1.ID, v2.ID });

            Assert.IsInstanceOfType(rv.Model, typeof(SchoolBatchVM));

            SchoolBatchVM vm = rv.Model as SchoolBatchVM;

            vm.Ids = new Guid[] { v1.ID, v2.ID };
            _controller.DoBatchDelete(vm, null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <School>().Count(), 0);
            }
        }