Beispiel #1
0
        public void CalculateTotalPriceUsingTax(decimal productPrice, int taxRateValue, decimal expectedTotalPrice)
        {
            // Arrange
            var product = new Product(
                new ProductName("C# for dummies"),
                new Upc(123),
                new Price(productPrice));

            var taxRate = new TaxRate(taxRateValue);

            // Act
            var totalPrice = product.Apply(taxRate);

            // Assert
            totalPrice.PriceBeforeTax.Value.ShouldBe(productPrice);
            totalPrice.PriceAfterTax.Value.ShouldBe(expectedTotalPrice);
            totalPrice.TaxRate.Value.ShouldBe(taxRateValue);
        }
        public void CalculateDiscountFor(decimal productPrice, int taxRateValue, int discountValue, decimal expectedTotalPrice)
        {
            // Arrange
            var product = new Product(
                new ProductName("C# for dummies"),
                new Upc(123),
                new Price(productPrice));

            var taxRate  = new TaxRate(taxRateValue);
            var discount = new Discount(discountValue);

            // Act
            var regularPrice = product.Apply(taxRate);
            var totalPrice   = regularPrice.Apply(discount);

            // Assert
            totalPrice.PriceAfterDiscount.Value.ShouldBe(expectedTotalPrice);
        }