Beispiel #1
0
        public void BatchDeleteTest()
        {
            Customers v1 = new Customers();
            Customers v2 = new Customers();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.CusName      = "FnN6ZV7";
                v1.CusGrade     = SCMSupplyChain.Model.CusGrade.VIP1;
                v1.CusCompany   = "32bio";
                v1.CusMan       = "B7358aReV";
                v1.CusTelephone = "uohl9Ebf";
                v1.CusDesc      = "FIpOlvhn";
                v2.CusName      = "3TkrCGcR";
                v2.CusGrade     = SCMSupplyChain.Model.CusGrade.VIP4;
                v2.CusCompany   = "hNL3";
                v2.CusMan       = "ZS4IJLc0";
                v2.CusTelephone = "xXR6AgyP";
                v2.CusDesc      = "R41Wk";
                context.Set <Customers>().Add(v1);
                context.Set <Customers>().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))
            {
                var data1 = context.Set <Customers>().Find(v1.ID);
                var data2 = context.Set <Customers>().Find(v2.ID);
                Assert.AreEqual(data1, null);
                Assert.AreEqual(data2, null);
            }

            rv = _controller.BatchDelete(new string[] {});
            Assert.IsInstanceOfType(rv, typeof(OkResult));
        }