示例#1
0
        public void TesteValorInicialZerado()
        {
            var service = new CalculoServices(new JurosCompostosValidator());

            var result = service.JurosCompostos(new JurosCompostosDto
            {
                Meses        = 9,
                ValorInicial = 0
            });

            Assert.NotNull(result);
            Assert.Equal(1, result.Errors.Count);
        }
示例#2
0
        public object Get([FromQuery] JurosCompostosViewModel vm)
        {
            try
            {
                var dto = _calculoServices.JurosCompostos(_mapper.Map <JurosCompostosViewModel, JurosCompostosDto>(vm));
                if (dto.Errors.Count > 0)
                {
                    return(BadRequest(CalculadoraFinanceiraResult(dto)));
                }

                return(Ok(dto.ValorFinal));
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
示例#3
0
        public void TestarJurosCompostos()
        {
            var service = new CalculoServices(new JurosCompostosValidator());

            var result = service.JurosCompostos(new JurosCompostosDto
            {
                Meses        = 5,
                ValorInicial = 100
            });
            var expected = new JurosCompostosDto
            {
                Meses        = 5,
                ValorInicial = 100,
                ValorFinal   = 105.10100501M
            };

            Assert.NotNull(result);
            Assert.Equal(result.Errors.Count, expected.Errors.Count);
            Assert.Equal(result.ValorFinal, expected.ValorFinal.Truncar(2));
        }