public void BeforeEach() { _basket = new Basket(); var shopCatalogue = new ShopCatalogue(); var currentOffers = new CurrentOffers(); currentOffers.RegisterDeal(new BreadAndButterDeal(), shopCatalogue.LookupPrice(new Bread()).NetPence / 2); currentOffers.RegisterDeal(new MultibuyMilkDeal(), shopCatalogue.LookupPrice(new Milk()).NetPence); _checkout = new Checkout(shopCatalogue, currentOffers); }
public void It_does_not_give_discount_when_deal_does_not_apply() { var items = new Collection <IPurchaseable> { new Bread(), new Butter() }; var unit = new CurrentOffers(); var deal = Substitute.For <IDeal>(); deal.TimesEligible(items).Returns(0); unit.RegisterDeal(deal, 100); Assert.That(unit.GetApplicable(items).NetPence, Is.EqualTo(0)); }
public void It_gives_discount_when_deal_applies_twice() { var items = new Collection <IPurchaseable> { new Bread(), new Butter() }; var unit = new CurrentOffers(); var deal = Substitute.For <IDeal>(); var timesApplicable = 2; deal.TimesEligible(items).Returns(timesApplicable); var discount = 100; unit.RegisterDeal(deal, discount); Assert.That(unit.GetApplicable(items).NetPence, Is.EqualTo(-discount * timesApplicable)); }