예제 #1
0
        public void BatchDeleteTest()
        {
            user v1 = new user();
            user v2 = new user();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.DCID     = AddDC();
                v1.DeptID   = AddDept();
                v1.ITCode   = "XML";
                v1.Password = "******";
                v1.Name     = "LxL";
                v2.DCID     = v1.DCID;
                v2.DeptID   = v1.DeptID;
                v2.ITCode   = "pUAF";
                v2.Password = "******";
                v2.Name     = "xCEMR";
                context.Set <user>().Add(v1);
                context.Set <user>().Add(v2);
                context.SaveChanges();
            }

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

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

            userBatchVM vm = rv.Model as userBatchVM;

            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 <user>().Count(), 0);
            }
        }