Пример #1
0
        public void GetPromoOneShouldReturnProperPromo()
        {
            //  Arrange
            PromoRepository promoRepo = new PromoRepository();

            //  Act
            Promo promoOne = promoRepo.GetPromoOne();

            //  Assert
            Assert.True(IsTestPromoOne(promoOne));
        }
Пример #2
0
        public void CheckCalculateCalculateCostsCalculatesCorrectly(int buttersQty, int milksQty, int breadsQty, decimal finalCost)
        {
            //  Arrange
            IPromoRepository   promoRepository   = new PromoRepository();
            IProductRepository productRepository = new ProductRepository();
            List <IPromo>      testPromosList    = new List <IPromo>()
            {
                promoRepository.GetPromoOne(), promoRepository.GetPromoTwo()
            };
            List <IProduct>  testProductsList = productRepository.GetProducts(buttersQty, milksQty, breadsQty);
            IGroceriesBasket basket           = new GroceriesBasket();

            basket.AddProducts(testProductsList);
            ICostCalculator costCalculator = new CostCalculator(basket, testPromosList);

            //  Act
            costCalculator.CalculateCosts();

            //  Assert that all the involved Costs are as they should be
            Assert.Equal(testProductsList.Sum(product => product.Price), costCalculator.TotalCost);                                 //  Total Cost of the Items
            Assert.Equal(testPromosList.Sum(promo => promo.CalculateDeduction(testProductsList)), costCalculator.PromosDeductions); //  Total Deductions from the applied Promos
            Assert.Equal(finalCost, costCalculator.FinalCost);                                                                      //  Final Cost
        }