private ObjectReplyDTO <object> CalculoJurosCompostos(CalculoValuesDto calcValues) { var result = new ObjectReplyDTO <object>(); try { var financiamento = new Financiamento { Juros = Convert.ToDouble(GetJuros().Result), Periodo = calcValues.Periodo, ValorInicial = calcValues.ValorInicial }; var valorTotal = financiamento.GetValorFinal(); result.Message = $"Valor final para um periodo de {calcValues.Periodo} meses."; result.ObjectReplyEntity = valorTotal; result.StatusReplyCode = ObjectReplyEnum.Success; } catch (Exception ex) { result.Message = ex.Message; result.ObjectReplyEntity = null; result.StatusReplyCode = ObjectReplyEnum.BusinessError; } return(result); }
public void Get_InlineData_ReturnsOkResult(int periodo, double valorInicial) { var fakeData = new CalculoValuesDto() { Periodo = periodo, ValorInicial = valorInicial }; // Act var okResult = _controller.Get(fakeData); // Assert Assert.Equal("BusinessError", okResult.StatusReply); }
public void Get_ReturnsOkResult() { var fakeData = new CalculoValuesDto() { Periodo = 5, ValorInicial = 100 }; // Act var okResult = _controller.Get(fakeData); // Assert Assert.Equal("Success", okResult.StatusReply); }
public ObjectReplyDTO <object> CalculaJuros(CalculoValuesDto calcValues) { var validator = new CalculoValuesDtoValidator(); var results = validator.Validate(calcValues); if (!results.IsValid) { var validatorResult = new ObjectReplyDTO <object>(); foreach (var failure in results.Errors) { validatorResult.StatusReplyCode = ObjectReplyEnum.BusinessError; string msg = $"Propriedade : {failure.PropertyName} => Erro: {failure.ErrorMessage}"; validatorResult.Message += msg; } return(validatorResult); } return(CalculoJurosCompostos(calcValues)); }
public ObjectReplyDTO <object> Get([FromQuery] CalculoValuesDto calcValues) { var result = _calculo.CalculaJuros(calcValues); return(result); }