示例#1
0
        public void BatchDeleteTest()
        {
            Category v1 = new Category();
            Category v2 = new Category();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Name             = "RBJ";
                v1.Seq              = 52;
                v1.FileAttachmentId = AddFileAttachment();
                v2.Name             = "fqP";
                v2.Seq              = 90;
                v2.FileAttachmentId = v1.FileAttachmentId;
                context.Set <Category>().Add(v1);
                context.Set <Category>().Add(v2);
                context.SaveChanges();
            }

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

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

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

            rv = _controller.BatchDelete(new string[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }
示例#2
0
        public void BatchDeleteTest()
        {
            Category v1 = new Category();
            Category v2 = new Category();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Name = "ttbc6G";
                v2.Name = "sEXfPP9s";
                context.Set <Category>().Add(v1);
                context.Set <Category>().Add(v2);
                context.SaveChanges();
            }

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

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

            CategoryBatchVM vm = rv.Model as CategoryBatchVM;

            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 <Category>().Count(), 2);
            }
        }