Ejemplo n.º 1
0
        public void GetDiscount_With_Valid_Client_Type_Should_Return_Valid_Price(decimal price, int type, decimal expectedResult)
        {
            //arrange
            User user = new User()
            {
                UserType = type
            };

            //act
            decimal actualResult = _sut.GetDiscount(user, price);

            Assert.AreEqual(expectedResult, actualResult);
        }
Ejemplo n.º 2
0
        public decimal GetProductsPrice(User user, IList <Product> products)
        {
            decimal result = 0;

            foreach (var product in products)
            {
                result += product.Price;
            }
            return(_discountHelper.GetDiscount(user, result));
        }
Ejemplo n.º 3
0
        public decimal GetTotalPrice()
        {
            decimal totalPrice = 0;

            var basketProducts      = _basket.GetBasketProducts;
            var uniqueProductsCount = basketProducts.Count;

            var discountSize = _discountHelper.GetDiscount(uniqueProductsCount);

            foreach (var key in basketProducts.Keys)
            {
                totalPrice += key.Price * (basketProducts[key] - discountSize);
            }

            return(totalPrice);
        }
Ejemplo n.º 4
0
        public IEnumerable <ProductDataContract> GetProducts()
        {
            var list = m_dbe.GetProducts();
            List <ProductDataContract> result = new List <ProductDataContract>();

            foreach (var p in list)
            {
                // маппинг сущности на ProductDataContract
                ProductDataContract pdc = new ProductDataContract
                {
                    id       = p.id,
                    Name     = p.Name,
                    Category = p.Category,
                    Price    = p.Price - m_dh.GetDiscount(p.Price)
                };

                result.Add(pdc);
            }

            return(result);
        }