public void Calculate_WhenNoItems_ReturnsZero() { _offersService.Setup(_ => _.GetAllDiscounts(new List <string>(), _itemCatalogue.Object)).Returns(0); var sut = new Checkout(_itemCatalogue.Object, _offersService.Object); Assert.That(sut.Calculate(_basket.Object), Is.EqualTo(0)); }
public void WhenICalculateTheTotal() { IOffersService offersService = new OffersService(); offersService.AddOffer(new BuyThreeMilksGetFourthFreeOffer()); offersService.AddOffer(new BuyTwoButtersAndGetABreadHalfPriceOffer()); var checkout = new Checkout(new ItemCatalogue(), offersService); Total = checkout.Calculate(_basket); }
public void Calculate_WhenItemsAndDiscounts_ReturnsTotal() { var scannedItems = new List <string> { Item1, Item2 }; _itemCatalogue.Setup(_ => _.LookupPrice(Item1)).Returns(Item1Price); _itemCatalogue.Setup(_ => _.LookupPrice(Item2)).Returns(Item2Price); _offersService.Setup(_ => _.GetAllDiscounts(scannedItems, _itemCatalogue.Object)).Returns(TotalDiscount); _basket.SetupSequence(_ => _.Take()) .Returns(Item1) .Returns(Item2) .Returns((string)null); var sut = new Checkout(_itemCatalogue.Object, _offersService.Object); Assert.That(sut.Calculate(_basket.Object), Is.EqualTo(Item1Price + Item2Price + TotalDiscount)); }