Пример #1
0
        public void GetTotalPricewithoutSpecialOffers()
        {
            var pc = new ProductCheckout()
            {
                Id       = 3,
                Quantity = 4,
                Price    = 1.80
            };
            IList <ProductCheckout> lpc = new List <ProductCheckout> {
                pc
            };

            ProductCheckout.CalculateTotalPrice(lpc);
            //7.2 is correct answer can change thsi to any other number to see test fail
            Assert.AreEqual("7.2", ProductCheckout.CalculateTotalPrice(lpc).ToString());
        }
Пример #2
0
        public void GetTotalPricewithSpecialOffers()
        {
            var pc = new ProductCheckout()
            {
                Id            = 1,
                Quantity      = 8,
                SpecialOffers = "3 for 1.30",
                Price         = 0.5
            };
            IList <ProductCheckout> lpc = new List <ProductCheckout> {
                pc
            };

            ProductCheckout.CalculateTotalPrice(lpc);
            //3.6 is correct answer can change thsi to any other number to see test fail
            Assert.AreEqual("3.6", ProductCheckout.CalculateTotalPrice(lpc).ToString());
        }
Пример #3
0
        // POST: api/ProductCheckout
        public double Post([FromBody] string value)
        {
            IList <ProductCheckout> pc = JsonConvert.DeserializeObject <IList <ProductCheckout> >(value);

            return(ProductCheckout.CalculateTotalPrice(pc));
        }