public void Scan2AItemsAndBShouldReturn45()
        {
            var chk = new Checkout();

            chk.Scan("B");
            chk.Scan("B");
            Assert.AreEqual(45, chk.GetTotal());
        }
        public void ScanAItemAndAShouldReturn80()
        {
            var chk = new Checkout();

            chk.Scan("A");
            chk.Scan("A");
            Assert.AreEqual(100, chk.GetTotal());
        }
Exemple #3
0
        public void WhenScanningTwoBs_CheckoutShouldApplyOffer()
        {
            var checkout = new Checkout(new OfferCalculator());

            checkout.Scan("B");
            checkout.Scan("B");
            Assert.AreEqual(45, checkout.GetTotalPrice());
        }
Exemple #4
0
        public void WhenScanningMulitpleAs_CheckoutShouldCountSumOfAs()
        {
            var checkout = new Checkout(new OfferCalculator());

            checkout.Scan("A");
            checkout.Scan("A");
            Assert.AreEqual(100, checkout.GetTotalPrice());
        }
        public void can_scan_two_items_and_get_total()
        {
            var checkout = new Checkout();

            checkout.Scan(_item1);
            checkout.Scan(_item2);
            Assert.Equal(80, checkout.GetTotal(_offers));
        }
        public void Scan3AItemsAnd1BItemShouldReturn160()
        {
            var chk = new Checkout();

            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("B");
            Assert.AreEqual(160, chk.GetTotal());
        }
Exemple #7
0
        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);
        }
Exemple #8
0
        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 void can_scan_items_with_and_without_offers_at_checkout()
        {
            var checkout = new Checkout();

            ScanItemMultipleTimes(checkout, _item1, 6); // total = 300, discount = 40
            ScanItemMultipleTimes(checkout, _item2, 4); // total = 120, discount = 30
            checkout.Scan(_item3);                      // total = 20, no discount
            checkout.Scan(_item4);                      // total = 15, no discount
            var expectedSubTotal = 455;
            var expectedDiscount = 70;
            var expectedTotal    = expectedSubTotal - expectedDiscount;

            Assert.Equal(expectedTotal, checkout.GetTotal(_offers));
        }
Exemple #10
0
 public void TestIncremental()
 {
     Assert.Equal(0, co.Total);
     co.Scan('A');
     Assert.Equal(50, co.Total);
     co.Scan('B');
     Assert.Equal(80, co.Total);
     co.Scan('A');
     Assert.Equal(130, co.Total);
     co.Scan('A');
     Assert.Equal(160, co.Total);
     co.Scan('B');
     Assert.Equal(175, co.Total);
 }
Exemple #11
0
        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);
        }
        public void ScanBItemShouldReturn30()
        {
            var chk = new Checkout();

            chk.Scan("B");
            Assert.AreEqual(30, chk.GetTotal());
        }
        public void can_scan_a_single_item_and_get_total()
        {
            var checkout = new Checkout();

            checkout.Scan(_item1);
            Assert.Equal(50, checkout.GetTotal(_offers));
        }
Exemple #14
0
        public void WhenSkuIsA_CheckoutShouldReturn50()
        {
            var checkout = new Checkout(new OfferCalculator());

            checkout.Scan("A");
            Assert.AreEqual(50, checkout.GetTotalPrice());
        }
Exemple #15
0
        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();
                }
            }
        }
 private void ScanItemMultipleTimes(Checkout checkout, Item item, int numberOfTimesToScan)
 {
     for (int i = 0; i < numberOfTimesToScan; i++)
     {
         checkout.Scan(item);
     }
 }
        public void ScanDItemShouldReturn15()
        {
            var chk = new Checkout();

            chk.Scan("D");
            Assert.AreEqual(15, chk.GetTotal());
        }
        public void ScanCItemShouldReturn20()
        {
            var chk = new Checkout();

            chk.Scan("C");
            Assert.AreEqual(20, chk.GetTotal());
        }
        public void ScanOneItem_TotalIsValueItem(char item, int total)
        {
            // Arrange
            var checkout = new Checkout();

            // Act
            checkout.Scan(item);

            // Assert
            Assert.AreEqual(total, checkout.Total);
        }
Exemple #20
0
        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 ScanOneItem_TotalIsValueItem(char item, double total)
        {
            // Arrange
            var checkout = new Checkout();

            // Act
            checkout.Scan(item);

            // Assert
            Assert.AreEqual(total, checkout.Total);
        }
        public void Scan6AItemsAnd2BItemShouldReturn305()
        {
            var chk = new Checkout();

            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("B");
            chk.Scan("B");
            Assert.AreEqual(305, chk.GetTotal());
        }
        private void ScanMultipleItems(string items, double 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);
        }
        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);
        }
Exemple #25
0
        public static void Main()
        {
            Checkout chOut = new Checkout();

            chOut.Scan('A');
            chOut.Scan('A');
            chOut.Scan('A');
            chOut.Scan('A');
            chOut.Scan('B');
            chOut.Scan('B');


            Console.WriteLine("Total price: " + chOut.Total);
            Console.ReadLine();
        }
 private void ScanItems(Checkout checkout, string items)
 {
     List<string> itemList = new List<string>(items.Split(','));
     itemList.ForEach(item => checkout.Scan(item));
 }
Exemple #27
0
        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 Scan7AItemsAnd2BItemAnd2DItemsAnd2cItemsShouldReturn425()
        {
            var chk = new Checkout();

            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("A");
            chk.Scan("B");
            chk.Scan("B");
            chk.Scan("C");
            chk.Scan("C");
            chk.Scan("D");
            chk.Scan("D");
            Assert.AreEqual(425, chk.GetTotal());
        }