public void When_Buy1Book_Expect_ItsPrice() { IBasketCalculator calc = new InfrastructureLayer.BasketCalculators.BasketCalcTechRule(); decimal price = calc.CalculateCatalogPrice(new List <Catalog>() { Book1 }); Assert.AreEqual(price, Book1.Price); }
public void When_BuyBooksInSameGroup_Expect_DiscountForTheFirstOnly() { IBasketCalculator calc = new InfrastructureLayer.BasketCalculators.BasketCalcTechRule(); decimal price = calc.CalculateCatalogPrice(new List <Catalog>() { Book1, Book1, Book1, Book2, Book2 }); Assert.AreEqual(Book1.Price * 3 + Book2.Price * (1 - Book2.Category.Discount) + Book2.Price, price); }
public void When_BuyMoreThanAvaliableBooks_Expect_Exception() { IBasketCalculator calc = new InfrastructureLayer.BasketCalculators.BasketCalcTechRule(); NotEnoughInventoryException exception = Assert.Throws <NotEnoughInventoryException>(() => calc.CalculateCatalogPrice(new List <Catalog>() { Book2, Book2, Book2 })); Assert.AreEqual(Book2.Name, exception.Missing.First().Name); Assert.AreEqual(Book2.Quantity, exception.Missing.First().Quantity); }
public void When_BuyNullBooks_Expect_Exception() { IBasketCalculator calc = new InfrastructureLayer.BasketCalculators.BasketCalcTechRule(); Assert.Throws <ArgumentOutOfRangeException>(() => calc.CalculateCatalogPrice(null)); }