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"); }
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"); }