Esempio n. 1
0
        public void DeleteTest()
        {
            user v = new user();

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.DCID     = AddDC();
                v.DeptID   = AddDept();
                v.ITCode   = "XML";
                v.Password = "******";
                v.Name     = "LxL";
                context.Set <user>().Add(v);
                context.SaveChanges();
            }

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

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

            userVM vm = rv.Model as userVM;

            v         = new user();
            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 <user>().Count(), 0);
            }
        }