예제 #1
0
        public void DiscountWasSuccessfullyApplied()
        {
            // scan all items in temp db.
            foreach (var product in _productsDictionary)
            {
                _checkout.Scan(product.Value);
            }

            // Call discount service, with the _checkout in the constructor.
            var discount = new Discount(_checkout);

            // store original price in variable
            var originalPrice = _checkout.GetTotalPrice();

            // Run promotions through discount service
            var prices = discount.GetDiscountedPrice(_promotionsDictionary);

            // Apply discount with tuples
            _checkout.ApplyDiscounts(prices);

            var discountedPrice = _checkout.GetTotalPrice();

            Assert.Multiple(() =>
            {
                Assert.That(discount, Is.Not.Null);
                Assert.That(discount.GetProducts(), Is.Not.Null);
                // Confirm that discounted price is in fact discounted
                Assert.That(discountedPrice, Is.LessThan(originalPrice));
            });
        }