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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.SupplierName  = "bem";
                v1.Contract      = "uQte8AWkm";
                v1.ContractPhone = "OX9Psxo";
                v2.SupplierName  = "16Oix";
                v2.Contract      = "V7qcvn";
                v2.ContractPhone = "ryFK9";
                context.Set <Supplier>().Add(v1);
                context.Set <Supplier>().Add(v2);
                context.SaveChanges();
            }

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

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

            SupplierBatchVM vm = rv.Model as SupplierBatchVM;

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