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

            using (var context = new FrameworkContext(_seed, DBTypeEnum.Memory))
            {
                v1.ITCode   = "itcode";
                v1.Name     = "name";
                v1.Password = "******";
                v2.ITCode   = "itcode2";
                v2.Name     = "name2";
                v2.Password = "******";
                context.Set <FrameworkUserBase>().Add(v1);
                context.Set <FrameworkUserBase>().Add(v2);
                context.SaveChanges();
            }


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

            Assert.IsInstanceOfType(rv, typeof(OkObjectResult));

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

            rv = _controller.BatchDelete(new Guid[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }
예제 #2
0
        public void BatchDeleteTest()
        {
            FrameworkUserBase v1 = new FrameworkUserBase();
            FrameworkUserBase v2 = new FrameworkUserBase();

            using (var context = new FrameworkContext(_seed, DBTypeEnum.Memory))
            {
                v1.ITCode   = "itcode";
                v1.Name     = "name";
                v1.Password = "******";
                v2.ITCode   = "itcode2";
                v2.Name     = "name2";
                v2.Password = "******";
                context.Set <FrameworkUserBase>().Add(v1);
                context.Set <FrameworkUserBase>().Add(v2);
                context.SaveChanges();
            }

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

            Assert.IsInstanceOfType(rv.Model, typeof(FrameworkUserBatchVM));
            (rv.Model as FrameworkUserBatchVM).ListVM.DoSearch();

            FrameworkUserBatchVM vm = rv.Model as FrameworkUserBatchVM;

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

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