Example #1
0
        public async Task Delete_ReturnsNotFoundResult_WhenAluguerDoesntExist()
        {
            var controller = new AlugueresController(_context);

            var result = await controller.Delete(0);

            Assert.IsType <NotFoundResult>(result);
        }
Example #2
0
        public async Task Delete_ReturnsNotFoundResult_WhenIdIsNull()
        {
            var controller = new AlugueresController(_context);

            var result = await controller.Delete(null);

            var viewResult = Assert.IsType <NotFoundResult>(result);
        }
Example #3
0
        public async Task Delete_ReturnsViewResult_WhenAluguerExist()
        {
            var controller = new AlugueresController(_context);

            var result = await controller.Delete(3);

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <Aluguer>(viewResult.ViewData.Model);

            Assert.NotNull(model);
            Assert.Equal(3, model.AluguerId);

            // Estes testes deveriam estar separados em diferentes métodos de teste!
            Assert.NotNull(model.Carro);
            Assert.NotNull(model.Cliente);
        }