예제 #1
0
        public void Test_CalculaJuros_ResponseOk()
        {
            // Arrange
            decimal valorInicial = 100;
            int     meses        = 5;

            // Act
            var data = _controller.CalculaJuros(valorInicial, meses);

            // Assert
            Assert.IsType <OkObjectResult>(data);
        }
예제 #2
0
        public async Task Test()
        {
            // Arrange
            var controle = new CalculaJurosController(_logger, _jurosService);

            // Act
            var resp = await controle.CalculaJuros(100.00, 5);

            // Assert
            Assert.Equal(105.10M, resp);
        }
        public async Task CalculaJuros_Sucesso()
        {
            //arrange
            var valorInicial = 100;
            var meses        = 5;

            var calculaJuroscontroller =
                new CalculaJurosController(_jurosServicos);

            //act
            var valorFinal = await calculaJuroscontroller.CalculaJuros(valorInicial, meses);

            //assert
            Assert.True(valorFinal == "105,10");
        }
예제 #4
0
        public async Task DeveRetornar400BadRequest()
        {
            //arrange
            decimal valorInicial = 0;
            int     meses        = 0;

            apiJurosClientMock.Setup(s => s.ObterTaxa()).ReturnsAsync("0,01");
            CalculaJurosController calculaJurosController = new CalculaJurosController(apiJurosClientMock.Object);

            //Action
            ObjectResult objectResult = await calculaJurosController.CalculaJuros(valorInicial, meses) as ObjectResult;

            //Assert
            Assert.Equal(StatusCodes.Status400BadRequest, objectResult.StatusCode);
            Assert.Equal(0, apiJurosClientMock.Invocations.Count);
        }
예제 #5
0
        public async Task DeveRetornar200Ok()
        {
            //arrange
            decimal valorInicial = 100;
            int     meses        = 5;
            string  resultado    = "105,10";

            apiJurosClientMock.Setup(s => s.ObterTaxa()).ReturnsAsync("0,01");
            CalculaJurosController calculaJurosController = new CalculaJurosController(apiJurosClientMock.Object);

            //Action
            ObjectResult objectResult = await calculaJurosController.CalculaJuros(valorInicial, meses) as ObjectResult;

            //Assert
            Assert.Equal(StatusCodes.Status200OK, objectResult.StatusCode);
            Assert.Equal(resultado, objectResult.Value);

            apiJurosClientMock.Verify(x => x.ObterTaxa(), Times.Once());
            Assert.Equal(1, apiJurosClientMock.Invocations.Count);
        }