Exemplo n.º 1
0
        public void TestEditG()
        {
            var db         = new CsK23T3bEntities();
            var controller = new OrderManagerController();
            var result0    = controller.Edit(0);

            Assert.IsInstanceOfType(result0, typeof(HttpNotFoundResult));
            var item    = db.Orders.First();
            var result1 = controller.Edit(item.Order_ID) as ViewResult;

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

            Assert.AreEqual(item.Order_ID, model.Order_ID);
        }
Exemplo n.º 2
0
        public void TestEditP()
        {
            var db    = new CsK23T3bEntities();
            var model = new Order
            {
                Order_ID       = db.Orders.AsNoTracking().First().Order_ID,
                Deliver_Status = 1
            };
            var controller = new OrderManagerController();

            using (var scope = new TransactionScope())
            {
                var result = controller.Edit(model, model.Deliver_Status);
                var view   = result as ViewResult;

                var redirect = result as RedirectToRouteResult;
                Assert.IsNotNull(redirect);
                Assert.AreEqual("Index", redirect.RouteValues["action"]);
                var item = db.Orders.Find(model.Order_ID);
                Assert.IsNotNull(item);
                Assert.AreEqual(item.Deliver_Status, model.Deliver_Status);
            }
        }