Exemplo n.º 1
0
        public async void CalculateTrolley_WhenTrolleyInfoIsNull_ReturnsZero()
        {
            // Arrange
            var sutFactory           = new SutTrolleyCalculatorFactory();
            var sutTrolleyCalculator = sutFactory.Create();

            // Act
            var result = await sutTrolleyCalculator.CalculateTrolley(null);

            // Assert
            result.Should().Be(0);
        }
Exemplo n.º 2
0
        public void CalculateTrolley_WhenTrolleyInfoPropertyIsNull_ReturnsZero(TrolleyInfo trolleyInfo)
        {
            // Arrange
            var sutFactory           = new SutTrolleyCalculatorFactory();
            var sutTrolleyCalculator = sutFactory.Create();

            // Act
            Func <Task> action = async() => await sutTrolleyCalculator.CalculateTrolley(trolleyInfo);

            // Assert
            action.Should().ThrowExactlyAsync <ArgumentException>()
            .WithMessage("Products, Quantities and Specials properties cannot be null.");
        }
Exemplo n.º 3
0
        public async void CalculateTrolley_WhenTrolleyInfoIsValid_ReturnsTotalReceivedFromTheExternalApi()
        {
            // Arrange
            var     trolleyInfo    = new TrolleyInfo();
            decimal expectedResult = 10.2m;
            var     sutFactory     = new SutTrolleyCalculatorFactory();

            sutFactory.SetupCalculatorTrolleyApiResult(trolleyInfo, expectedResult);

            var sutTrolleyCalculator = sutFactory.Create();

            // Act
            var result = await sutTrolleyCalculator.CalculateTrolley(trolleyInfo);

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