Ejemplo n.º 1
0
        public void TestProductsDiscountOverflow()
        {
            Products product = new Products();

            product.Id    = 1;
            product.Price = 10;

            Assert.AreEqual(product.Price, 10);

            product.AddDiscount(110);

            Assert.AreEqual(product.Price, 10);
        }
Ejemplo n.º 2
0
        public void TestProductsDiscountUnderZero()
        {
            Products product = new Products();

            product.Id    = 1;
            product.Price = 10;

            Assert.AreEqual(product.Price, 10);

            product.AddDiscount(100);

            Assert.AreEqual(product.Price, 10);
        }
Ejemplo n.º 3
0
        // GET: Products/Discount/5
        public ActionResult Discount(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Products products = db.Products.Find(id);

            if (products == null)
            {
                return(HttpNotFound());
            }

            products.AddDiscount(10);

            db.SaveChanges();

            return(RedirectToAction("Index"));
        }