public void ApplyDiscountCard_WithDefaultDiscountCard_CorrectTotalValue(int productsCount, decimal expectedResult)
        {
            var terminal = new PointOfSaleTerminal(
                new ProductsPriceSetBuilder()
                    .AddProduct(DefaultProductCode.ToString(), 100.0M, 3, 200.0M)
                    .GetAllProducts());
            var discountCard = CreateDefaultDiscountCard();

            ScanStringAsChars(terminal, new string(DefaultProductCode, productsCount));

            AssertDecimalEquals(expectedResult, terminal.CalculateTotal(discountCard));
        }
        public void ScanProductsSequence_WithDefaultPricesSet_CorrectTotalValue(string productCodes, decimal expectedResult)
        {
            var terminal = new PointOfSaleTerminal(
                new ProductsPriceSetBuilder()
                    .AddProduct("A", 1.25M, 3, 3.0M)
                    .AddProduct("B", 4.25M)
                    .AddProduct("C", 1.0M, 6, 5.0M)
                    .AddProduct("D", 0.75M)
                    .GetAllProducts());

            ScanStringAsChars(terminal, productCodes);

            AssertDecimalEquals(expectedResult, terminal.CalculateTotal());
        }
        public void DiscountRateChanges_WithDefaultDiscountCard_CorrectTotalValue(int productsCount, decimal expectedResult)
        {
            var discountCard = CreateDefaultDiscountCard();
            Func<int, decimal> scanItems = count =>
                {
                    var terminal = new PointOfSaleTerminal(
                        new ProductsPriceSetBuilder()
                            .AddProduct(DefaultProductCode.ToString(), 100.0M)
                            .GetAllProducts());
                    ScanStringAsChars(terminal, new string(DefaultProductCode, count));
                    return terminal.CalculateTotal(discountCard);
                };

            scanItems(productsCount);
            decimal actualResult = scanItems(1);

            AssertDecimalEquals(expectedResult, actualResult);
        }
        public void ScanNonExistingProduct_WithEmptyPricesSet_ExceptionThrown()
        {
            var terminal = new PointOfSaleTerminal(new PointOfSaleProduct[0]);

            Assert.Throws(typeof(ArgumentException), () => terminal.Scan("A"));
        }
 private void ScanStringAsChars(PointOfSaleTerminal terminal, string productCodes)
 {
     foreach(char ch in productCodes)
     {
         terminal.Scan(ch.ToString());
     }
 }