private void VerifyCalculation(BaseCaseMapping mapper, bool a, bool b, bool c, Engine.Model.CalculationType calc, decimal correctValue) { var result = mapper.Resolve(a, b, c, D, E, F).Result; Assert.AreNotEqual(result, Engine.Model.CalculationType.Error, "Calculation Type {calc} not mapped"); Assert.AreEqual(result.CalculationType, calc, "Calculation Type {calc} is mapped incorrectly"); Assert.AreEqual(result.CalculationValue, correctValue, "Calculation Type {calc} has invalid calculation result"); }
async Task <IActionResult> MapCalculationToResultsAndSend(bool a, bool b, bool c, int d, int e, int f, BaseCaseMapping mapper) { (ResultsDTO.X, ResultsDTO.Y) = await mapper.Resolve(a, b, c, d, e, f); if (ResultsDTO.X == Engine.Model.CalculationType.Error) { throw new HttpRequestException("Invalid request parameters"); } return(new ObjectResult(ResultsDTO)); }
private void VerifyInvalidInput(BaseCaseMapping mapper, bool a, bool b, bool c) { var result = mapper.Resolve(a, b, c, D, E, F).Result; Assert.AreEqual(result.CalculationType, Engine.Model.CalculationType.Error, "Invalid input returned an error"); // null is much faster at runtime than throwing an exception, so the calculation engine can be used in performance critical code? }