public ActionResult CombinedWith(decimal pa, decimal pb) { var calculation = new CombinedWithCalculation(pa, pb); var result = _calculatorService.Calculate(calculation); return(Ok(result)); }
public void CombinedWithCalculation_Should_Return_Approximate_Result(double op1, double op2, double epsylon) { //Arrange ICalculation combined = new CombinedWithCalculation(op1, op2); //Act double actual = combined.Calculate(); //Assert Assert.IsTrue(actual - 0.02 < epsylon); }
public void GetInputsForLogMessage_ReturnsExpectedResult() { // Arrange var pa = 0.7M; var pb = 0.8M; var calculation = new CombinedWithCalculation(pa, pb); // Act var result = calculation.GetInputsForLogMessage(); // Assert result.Should().Be("0.7 * 0.8"); }
public void Calculate_ReturnsExpectedResult() { // Arrange var pa = 0.7M; var pb = 0.8M; var calculation = new CombinedWithCalculation(pa, pb); // Act var result = calculation.Calculate(); // Assert result.Should().Be(0.56M); }
public void Validate_ValidParameters_ReturnsExpectedResult() { // Arrange var pa = 0.7M; var pb = 0.8M; var calculation = new CombinedWithCalculation(pa, pb); // Act var result = calculation.Validate(); // Assert var expected = new ValidationResult { IsValid = true }; result.Should().BeEquivalentTo(expected); }
public void Validate_InvalidParameters_ReturnsExpectedResult(decimal pa, decimal pb) { // Arrange var calculation = new CombinedWithCalculation(pa, pb); // Act var result = calculation.Validate(); // Assert var expected = new ValidationResult { IsValid = false, Errors = new List <Error> { new Error { ErrorCode = ErrorCode.InvalidParameters, ErrorMessage = "Parameters must be greater than or equal to 0 and less than or equal to 1" } } }; result.Should().BeEquivalentTo(expected); }