Example #1
0
        public void BatchDeleteTest()
        {
            Device v1 = new Device();
            Device v2 = new Device();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.ID        = "44tvMxOP9";
                v1.ProductId = AddProduct();
                v2.ProductId = v1.ProductId;
                context.Set <Device>().Add(v1);
                context.Set <Device>().Add(v2);
                context.SaveChanges();
            }

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

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

            DeviceBatchVM vm = rv.Model as DeviceBatchVM;

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