Exemplo n.º 1
0
        public void BatchDeleteTest()
        {
            Connection v1 = new Connection();
            Connection v2 = new Connection();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v1.Name     = "KgH";
                v1.Host     = "gMTL";
                v1.Port     = 12;
                v1.Database = "tBEa";
                v1.Username = "******";
                v1.Password = "******";
                v1.ID       = 10;
                v2.Name     = "us3obVjYg";
                v2.Host     = "Dv6R8YTw";
                v2.Port     = 61;
                v2.Database = "KGi";
                v2.Username = "******";
                v2.Password = "******";
                context.Set <Connection>().Add(v1);
                context.Set <Connection>().Add(v2);
                context.SaveChanges();
            }

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

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

            ConnectionBatchVM vm = rv.Model as ConnectionBatchVM;

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