예제 #1
0
        public void DeleteTest()
        {
            Connection v = new Connection();

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

            PartialViewResult rv = (PartialViewResult)_controller.Delete(v.ID.ToString());

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

            ConnectionVM vm = rv.Model as ConnectionVM;

            v         = new Connection();
            v.ID      = vm.Entity.ID;
            vm.Entity = v;
            _controller.Delete(v.ID.ToString(), null);

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                Assert.AreEqual(context.Set <Connection>().Count(), 0);
            }
        }