Exemplo n.º 1
0
        public void testCreateP()
        {
            var model = new BubleTea
            {
                Name    = "Hoa huong duong",
                Topping = "tran chau, banh flan",
                Price   = 0
            };
            var db         = new CS4PEEntities();
            var controller = new VLTeaController();

            using (var scope = new TransactionScope()){
                var result = controller.create(model);
                var view   = result as ViewResult;
                Assert.IsNotNull(view);
                Assert.IsInstanceOfType(view.Model, typeof(BubleTea));
                Assert.AreEqual(Resource1.PRICE_LESS_0, controller.ViewData.ModelState["Price"].Errors[0].ErrorMessage);

                model.Price = 26000;
                controller  = new VLTeaController();
                result      = controller.create(model);
                var redirect = result as RedirectToRouteResult;
                Assert.IsNotNull(redirect);
                Assert.AreEqual("Index", redirect.RouteValues["action"]);
                var item = db.BubleTeas.Find(model.id);
                Assert.IsNotNull(item);
                Assert.AreEqual(model.Name, item.Name);
                Assert.AreEqual(model.Topping, item.Topping);
                Assert.AreEqual(model.Price, item.Price);
            }
        }
Exemplo n.º 2
0
        public void TestCreateG()
        {
            var controller = new VLTeaController();
            var result     = controller.create();

            var view = result as ViewResult;

            Assert.IsNotNull(view);
        }