static void Main() { Database ds = new Database(); CheckoutKata.Checkout co = new CheckoutKata.Checkout(new Repository(ds)); Console.WriteLine("Begin scanning items. Type 'Total' when complete"); bool scanning = true; while (scanning) { var input = Console.ReadLine(); if (input != "Total") { co.Scan(input); } else { scanning = false; var totalprice = co.GetTotalPrice(); Console.WriteLine($"The total price is: {totalprice}"); Console.Read(); } } }
public CheckoutPricing() { subject = new Checkout( new ProductPricing("A", 50, 3, 20), new ProductPricing("B", 30, 2, 15), new ProductPricing("C", 20), new ProductPricing("D", 15)); }
public void ScanNoItems_TotalIsZero() { // Arrange var checkout = new Checkout(); // Act + Assert Assert.AreEqual(0, checkout.Total); }
public void CalculateTotal_NoItems_ReturnsZero() { var checkout = new Checkout(null); var total = checkout.CalculateTotal(); total.Should().Be(0); }
public void SimpleCheckoutTests_Setup() { pricingRules = new PricingRules(); pricingRules.Price("A", 10); pricingRules.Price("B", 20); pricingRules.MultibuyDiscount("A", 2, 15); checkout = new Checkout(pricingRules); }
public void ScanOneItem_TotalIsValueItem(char item, int total) { // Arrange var checkout = new Checkout(); // Act checkout.Scan(item); // Assert Assert.AreEqual(total, checkout.Total); }
public void CalculateTotal_OneItem_ReturnsItemsValue() { var prices = GetPrices(); var checkout = new Checkout(prices); checkout.Scan("A"); var total = checkout.CalculateTotal(); total.Should().Be(50); }
public void Setup() { var offers = new Offers(new List<Offer> { new Offer{SKU = 'A', Frequency = 3, Discount = 20}, new Offer{SKU = 'B', Frequency = 2, Discount = 15} }); var catalogue = new Catalogue(new Dictionary<char, int> {{'A', 50}, {'B', 30}, {'C', 20}, {'D', 15}}); _checkout = new Checkout(offers, catalogue); }
public void CalulateTotal_ItemsThatDontQualifyForOffer_ShouldBeSummed() { var prices = GetPrices(); var checkout = new Checkout(prices); checkout.Scan("A"); checkout.Scan("A"); var total = checkout.CalculateTotal(); total.Should().Be(100); }
public CheckoutTests() { // arrange for all tests var prices = new List<PricingStrategy>() { new MultiStockPricing('A', 50, 3, 130), new MultiStockPricing('B', 30, 2, 45), new IndividualStockPricing('C', 20), new IndividualStockPricing('D', 15) }; this.co = new Checkout(prices); }
public void CalculateTotal_TwoItems_ReturnsSumOfTwoItems() { var prices = GetPrices(); var checkout = new Checkout(prices); checkout.Scan("A"); checkout.Scan("B"); var total = checkout.CalculateTotal(); total.Should().Be(80); }
private void ScanMultipleItems(string items, int total) { // Arrange var checkout = new Checkout(); // Act for (int i = 0; i < items.Length; i++) { checkout.Scan(items[i]); } // Assert Assert.AreEqual(total, checkout.Total); }
public void CalulateTotal_ItemsThatQualifyForOfferOfDifferentKinds_OfferShouldBeAppliedToBoth() { var prices = GetPrices(); var checkout = new Checkout(prices); checkout.Scan("A"); checkout.Scan("A"); checkout.Scan("A"); checkout.Scan("B"); checkout.Scan("B"); var total = checkout.CalculateTotal(); total.Should().Be(175); }
static void Main(string[] args) { IList <ISpecialPrice> specialPrices = new List <ISpecialPrice> { new SpecialPrice(2, 2, 45), new SpecialPrice(1, 3, 130), }; IList <Product> products = new List <Product> { new Product(1, "A", 50, specialPrices[1]), new Product(2, "B", 30, specialPrices[0]), new Product(3, "C", 10, null), new Product(4, "D", 20, null), }; ICheckSpecialPrice specialPrice = new CheckSpecialPrice(); ICheckout checkout = new Checkout(specialPrice); checkout.ScanItem(products[1]); checkout.ScanItem(products[1]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[0]); checkout.ScanItem(products[1]); var total = checkout.GetTotalPrice(); Console.WriteLine("TOTAL IS: " + total); }
public void TestItemsThatDontExist() { Assert.AreEqual(0.00, Checkout.ProcessOrder("EFGH")); }
private void ScanItems(Checkout checkout, string items) { List<string> itemList = new List<string>(items.Split(',')); itemList.ForEach(item => checkout.Scan(item)); }
public void CalulateTotal_OneItemFromEachProduct_ReturnsSum() { var prices = GetPrices(); var checkout = new Checkout(prices); checkout.Scan("C"); checkout.Scan("D"); checkout.Scan("B"); checkout.Scan("A"); var total = checkout.CalculateTotal(); total.Should().Be(115); }
public void TestEmptyOrder() { Assert.AreEqual(0.00, Checkout.ProcessOrder("")); }
private static void OutputCheckoutCost(Checkout checkout) { Console.WriteLine("--- Current Cost: " + checkout.TotalBasketCost + " ---"); }
public void TestItemDDiscount(string order, double expected) { Assert.AreEqual(expected, Checkout.ProcessOrder(order)); }
public void TestMixedOrders(string order, double expected) { Assert.AreEqual(expected, Checkout.ProcessOrder(order)); }
public void TestOneOfEachItem() { Assert.AreEqual(120, Checkout.ProcessOrder("ABCD")); }
public void SetUp() { _checkout = new Checkout(); }