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); }
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."); }
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); }