コード例 #1
0
        public void NormalAbsoluteDiscount_WhenInitialAmountIs_100_And_30DiscountProvided_ThenReturns70()
        {
            // Arrange
            NormalSale            normalSale            = new NormalSale();
            AbsolutePriceStrategy absolutePriceStrategy = new AbsolutePriceStrategy(30);
            decimal price = 100;

            // Act
            normalSale.SetStrategy(absolutePriceStrategy);
            var result = normalSale.GetTotal(price);

            // Assert
            result.Should().Be(70);
        }
コード例 #2
0
        public void NormalPercentageDiscount_WhenInitialAmountIs_100_And_20PercentDiscountProvided_ThenReturns80()
        {
            // Arrange
            NormalSale           normalSale           = new NormalSale();
            PercentPriceStrategy percentPriceStrategy = new PercentPriceStrategy(20);
            decimal price = 100;

            // Act
            normalSale.SetStrategy(percentPriceStrategy);
            var result = normalSale.GetTotal(100);

            // Assert
            result.Should().Be(80);
        }