예제 #1
0
        public void NoPricingStrategy_When100_Then100()
        {
            // Arrange
            var myFacade = new MyFacade(100, new NullPricingStrategy());


            // Act
            var result = myFacade.getTotal();

            // Assert
            result.Should().Be(100);
        }
예제 #2
0
        public void AbsoluteDiscountOverThresholdStrategy(decimal threshold, decimal amount, decimal expectedResult)
        {
            // Arrange
            var absoluteDiscountOverThresholdStrategy = new AbsoluteDiscountOverThresholdStrategy(threshold, 10m);
            var myFacade = new MyFacade(amount, absoluteDiscountOverThresholdStrategy);

            // Act
            var result = myFacade.getTotal();

            // Assert
            result.Should().Be(expectedResult);
        }
예제 #3
0
        public void PercentageDiscount_WhenInitialAmountIs_100_And_20PercentDiscountProvided_ThenReturn80()
        {
            // Arrange

            var pricingStrategy = new PercentageDiscountStrategy(20);
            var myFacade        = new MyFacade(100, pricingStrategy);

            // Act
            var total = myFacade.getTotal();

            // Assert
            total.Should().Be(80);
        }
예제 #4
0
        public void DoubleDiscountAfterLunchStrategy_WhenBefore12_ThenSingleDiscount()
        {
            // Arrange
            var timeSourceMock = new Mock <ITimeSource>();

            timeSourceMock.Setup(x => x.Now).Returns(new DateTime(2018, 1, 1, 11, 59, 59));

            var doubleDiscountAfterLunchStrategy = new DoubleDiscountAfterLunchStrategy(timeSourceMock.Object, 10m);
            var myFacade = new MyFacade(100, doubleDiscountAfterLunchStrategy);

            // Act
            var result = myFacade.getTotal();

            timeSourceMock.Verify(x => x.Now, Times.Once);
            result.Should().Be(90);
        }