Пример #1
0
        public void BatchDeleteTest()
        {
            Report v1 = new Report();
            Report v2 = new Report();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Temperature = 36;
                v2.Temperature = 44;
                context.Set <Report>().Add(v1);
                context.Set <Report>().Add(v2);
                context.SaveChanges();
            }

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

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

            ReportBatchVM vm = rv.Model as ReportBatchVM;

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