public int Tests(int aItemCount = 0, int bItemCount = 0, int cItemCount = 0, int dItemCount = 0) { var aSku = new DiscountedSku(new Sku('A', 50), 3, 130); var bSku = new DiscountedSku(new Sku('B', 30), 2, 45); var cSku = new Sku('C', 20); var dSku = new Sku('D', 15); var pricing = new Pricing(aSku, bSku, cSku, dSku); var checkout = new store.Checkout(pricing); void callScan(string item, int itemCount) { var counter = itemCount; while (counter != 0) { checkout.Scan(item); counter--; } } callScan("A", aItemCount); callScan("B", bItemCount); callScan("C", cItemCount); callScan("D", dItemCount); return(checkout.GetTotalPrice()); }
public int ValidTests( char name, int unitPrice, int specialPriceItemCount, int specialPrice, int itemCount) { var itemCountMock = new Mock <IItemCount>(); itemCountMock.Setup(x => x.Value).Returns(itemCount); var skuMock = new Mock <IDiscountableSku>(); skuMock.Setup(x => x.Name).Returns(name); skuMock.Setup(x => x.UnitPrice).Returns(unitPrice); skuMock.Setup(x => x.GetPrice(It.IsAny <IItemCount>())).Returns((itemCount % specialPriceItemCount) * unitPrice); var target = new DiscountedSku(skuMock.Object, specialPriceItemCount, specialPrice); return(target.GetPrice(itemCountMock.Object)); }