Example #1
0
        public void GivenTwoProductWitMultipleSpecialShouldGiveMinPrice()
        {
            var trolleyCalculator = new TrolleyCalculatorService();
            var result            = trolleyCalculator.CalculateTotal(TwoProductWithMultipleSpecial());

            result.Should().Be(7);
        }
Example #2
0
        public void GivenSingleProductWitDifferentSpecialShouldGiveMinPrice()
        {
            var    trolleyCalculator = new TrolleyCalculatorService();
            Action action            = () => trolleyCalculator.CalculateTotal(DifferentSpecial());

            action.Should().Throw <ValidationException>();
        }
Example #3
0
        public void GivenSingleProductWithSpecialShouldGiveMinPrice()
        {
            var trolleyCalculator = new TrolleyCalculatorService();
            var result            = trolleyCalculator.CalculateTotal(SingleItemWithSpecial());

            result.Should().Be(4);
        }
        public void TrolleyTotal_No_Specials()
        {
            var trolleyCalculatorService = new TrolleyCalculatorService();
            var request = GetTrolleyCalculatorRequest("Test Product A", 100, 10, null);
            var total   = trolleyCalculatorService.CalculateTrolley(request);

            Assert.Equal(1000, total);
        }
        public void TrolleyTotal_Complex_Simple1()
        {
            var trolleyCalculatorService = new TrolleyCalculatorService();
            var trolleyTest = GetTrolleyTest("Simple1");

            var total = trolleyCalculatorService.CalculateTrolley(trolleyTest.Trolley);

            Assert.Equal(trolleyTest.Total, total);
        }
        public void TrolleyTotal_Single_Special()
        {
            var trolleyCalculatorService = new TrolleyCalculatorService();
            var request = GetTrolleyCalculatorRequest("Test Product A", 100, 10,
                                                      new List <(int, decimal)>()
            {
                (2, 160)
            }
                                                      );
            var total = trolleyCalculatorService.CalculateTrolley(request);

            Assert.Equal(800, total);
        }
        public void TrolleyTotal_Multiple_Specials_All_Taken()
        {
            var trolleyCalculatorService = new TrolleyCalculatorService();
            var request = GetTrolleyCalculatorRequest("Test Product A", 100, 11,
                                                      new List <(int, decimal)>()
            {
                (2, 160),
                (3, 210)
            }
                                                      );
            var total = trolleyCalculatorService.CalculateTrolley(request);

            Assert.Equal(790, total);
        }
        public void TrolleyTotal_No_Products()
        {
            var trolleyCalculatorService = new TrolleyCalculatorService();
            var request = new Trolley()
            {
                Specials = new List <Special>
                {
                    new Special(),
                    new Special(),
                    new Special(),
                    new Special()
                }
            };

            var total = trolleyCalculatorService.CalculateTrolley(request);

            Assert.Equal(0, total);
        }