public async Task <CalculoTaxaJurosDto> Handle(CalcularTaxaJurosCommand request, CancellationToken cancellationToken) { decimal taxaAtual = await _taxaJurosService.GetTaxaJurosAtual(cancellationToken); var taxaJuros = new CalculoTaxaJuros(request.ValorInicial, request.TempoMeses, taxaAtual); return(new CalculoTaxaJurosDto(taxaJuros.GetResultadoFormatted(2, CultureInfo.CurrentUICulture))); }
public void ReturnsCorrectResultOnCalculoTaxaJuros(decimal valorInicial, int tempoMeses, decimal taxaJuros, decimal resultadoEsperado) { var sut = new CalculoTaxaJuros(valorInicial, tempoMeses, taxaJuros); double result = (double)sut.Resultado; result.Should().BeApproximately((double)resultadoEsperado, MAX_DOUBLE_DIFF); }
public async Task <IActionResult> CalculaJuros([FromBody] CalcularTaxaJurosModel model) { if (!model.IsValid) { return(BadRequest()); } var taxaJuros = await _service.BuscarTaxaJuros(); var calculoTaxaJuros = new CalculoTaxaJuros(model.ValorInicial, model.Tempo, taxaJuros.Valor); return(Ok((CalcularTaxaJurosModelResult)calculoTaxaJuros)); }
public void CalculaJuros_ObtemValorFinal() { //Arrange var valorInicial = 100; var taxaJuros = 0.01; var tempo = 5; //Act var calculoTaxaJuros = new CalculoTaxaJuros(valorInicial, tempo, taxaJuros); //Assert Assert.Equal(105.10, calculoTaxaJuros.ValorFinal); }