Пример #1
0
        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)));
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }