Exemple #1
0
        public void ObterMotoristaPorIdInvalido()
        {
            //Arrange
            var mockMotoristaBusiness = new Mock <IMotoristaBusiness>();

            mockMotoristaBusiness.Setup(x => x.ObterPorId(1)).Returns(() => null);

            var mapperMock = new Mock <IMapper>();

            var motoristaController = new MotoristaController(mockMotoristaBusiness.Object, mapperMock.Object);

            //Act
            var result = motoristaController.ObterPorId(1);

            var notFoundResult = result as NotFoundResult;

            notFoundResult.StatusCode.Should().Be(404, "Resultado incorreto para um id inválido");
        }
Exemple #2
0
        public void ObterMotoristaPorIdValido()
        {
            //Arrange
            var mockMotoristaBusiness = new Mock <IMotoristaBusiness>();

            mockMotoristaBusiness.Setup(x => x.ObterPorId(1)).Returns(() => new Motorista());

            var mapperMock = new Mock <IMapper>();

            var motoristaController = new MotoristaController(mockMotoristaBusiness.Object, mapperMock.Object);

            //Act
            var result = motoristaController.ObterPorId(1);

            var okResult = result as OkObjectResult;

            //Assert
            okResult.StatusCode.Should().Be(200, "Resultado incorreto para um id válido");
        }