public async Task DivideStrategy_Success_Handled() { List <double> inputs = new List <double> { 1, 2, 3 }; CalculatorResponse expectedResponse = new CalculatorResponse(); expectedResponse.SetResult(0.16666, true, 200, new List <string>()); var computeResolver = new Mock <IComputeResolver>(); computeResolver.Setup(cr => cr.Compute(inputs)).ReturnsAsync(0.16666); ICalculatorService calculator = new CalculatorService(computeResolver.Object); var result = await calculator.Add(inputs); expectedResponse.Should().BeEquivalentTo(result); }
public async Task MultiplyStrategy_Failure_Handled() { List <double> inputs = new List <double> { 1, 2, 3 }; CalculatorResponse expectedResponse = new CalculatorResponse(); expectedResponse.SetResult(double.NaN, false, 500, new List <string>() { Resources.GenericException }); var computeResolver = new Mock <IComputeResolver>(); computeResolver.Setup(cr => cr.Compute(inputs)).ThrowsAsync(new Exception(Resources.GenericException)); ICalculatorService calculator = new CalculatorService(computeResolver.Object); var result = await calculator.Add(inputs); expectedResponse.Should().BeEquivalentTo(result); }