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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                v.AreaName = "AyD9qo";
                v.ParentId = AddParent();
                context.Set <Area>().Add(v);
                context.SaveChanges();
            }

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

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

            AreaVM vm = rv.Model as AreaVM;

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

            using (var context = new DataContext(_seed, DBTypeEnum.Memory))
            {
                var data = context.Set <Area>().Find(v.ID);
                Assert.AreEqual(data, null);
            }
        }
        public void DeleteAreaTest()
        {
            int id   = 123;
            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.DeleteArea(id));
            var controller = new AreaController(mock.Object);

            var result = controller.Delete(id);

            mock.VerifyAll();
            Assert.IsInstanceOfType(result, typeof(NoContentResult));
        }