public void TestDeleteG()
        {
            var controller = new VLTeaController();
            var result0    = controller.Delete(0);

            Assert.IsInstanceOfType(result0, typeof(HttpNotFoundResult));
            var db      = new CS4PEEntities();
            var item    = db.BubleTeas.First();
            var result1 = controller.Delete(item.id) as ViewResult;

            Assert.IsNotNull(result1);
            var model = result1.Model as BubleTea;

            Assert.IsNotNull(model);
            Assert.AreEqual(item.id, model.id);
        }
Esempio n. 2
0
        public void TestDelete()
        {
            var db         = new CS4PEEntities();
            var controller = new VLTeaController();

            var result = controller.Delete(0);

            Assert.IsInstanceOfType(result, typeof(HttpNotFoundResult));
            using (var scope = new TransactionScope())
            {
                var model = db.BubleTeas.AsNoTracking().First();
                result = controller.Delete(model.id);
                var redirect = result as RedirectToRouteResult;
                Assert.IsNotNull(redirect);
                Assert.AreEqual("Index", redirect.RouteValues["action"]);
                var item = db.BubleTeas.Find(model.id);
                Assert.IsNull(item);
            }
        }