Esempio n. 1
0
        public async Task GetCalculoJuros_BadRequest()
        {
            mockCalculaService.Setup(calcula => calcula.CalcularJuros(It.IsAny <decimal>(), It.IsAny <int>())).ReturnsAsync(decimal.Zero);
            CalculaController calculaController = new CalculaController(mockCalculaService.Object, mockProjetoService.Object);
            var result = await calculaController.GetCalculoJuros(decimal.Zero, 5);

            Assert.IsInstanceOf <BadRequestObjectResult>(result);
        }
Esempio n. 2
0
        public async Task GetCalculoJuros_Accepted()
        {
            mockCalculaService.Setup(calcula => calcula.CalcularJuros(It.IsAny <decimal>(), It.IsAny <int>())).ReturnsAsync(new decimal(105.10));
            CalculaController calculaController = new CalculaController(mockCalculaService.Object, mockProjetoService.Object);
            var result = await calculaController.GetCalculoJuros(new decimal(100), 5);

            Assert.IsInstanceOf <AcceptedResult>(result);
        }
Esempio n. 3
0
        public async Task GetCalculoJuros_ModelStateInvalid()
        {
            CalculaController calculaController = new CalculaController(mockCalculaService.Object, mockProjetoService.Object);

            calculaController.ModelState.AddModelError("Key", "errorMessage");
            var result = await calculaController.GetCalculoJuros(decimal.Zero, 1);

            Assert.IsFalse(calculaController.ModelState.IsValid);
            Assert.IsInstanceOf <BadRequestObjectResult>(result);
        }