예제 #1
0
        public void CalculateDiscount_ShouldBeZero_ProductPriceLessThanDiscount()
        {
            var totalPriceForTheProduct = 30;

            var discountStrategyMock = new Mock <IDiscountStrategy>();

            discountStrategyMock.Setup(x => x.CalculateDiscount(totalPriceForTheProduct)).Returns(-20);

            var discount = new DiscountConcrete(discountStrategyMock.Object);

            Assert.AreEqual(0, discount.CalculateDiscount(totalPriceForTheProduct));
        }
예제 #2
0
        public void CalculateDiscount_ShouldBeBiggerThanZero_ProductPriceGreaterThanDiscount()
        {
            var totalPriceForTheProduct = 500;

            var discountStrategyMock = new Mock <IDiscountStrategy>();

            discountStrategyMock.Setup(x => x.CalculateDiscount(totalPriceForTheProduct)).Returns(450);

            var discount = new DiscountConcrete(discountStrategyMock.Object);

            Assert.Greater(discount.CalculateDiscount(totalPriceForTheProduct), 0);
        }