public void NaoDeveAtualizarQuandoCargoNaoExistir() { Cargo cargo = new Cargo("Tester"); _cargoRepositoryMock = new Mock <ICargoRepository>(); _cargoRepositoryMock.Setup(mock => mock.Atualizar(It.IsAny <Cargo>())).Throws <Exception>(); ICargoService cargoService = new CargoService(_cargoRepositoryMock.Object); var mensagens = cargoService.Atualizar(cargo.Mapear(), cargo.Id); _cargoRepositoryMock.Verify(mock => mock.Atualizar(It.IsAny <Cargo>()), Times.Once()); Assert.Equal(1, mensagens.Count); }
public void DeveAtualizarCargo() { Cargo cargo = new Cargo("Tester"); _cargoRepositoryMock = new Mock <ICargoRepository>(); _cargoRepositoryMock.Setup(mock => mock.Atualizar(It.IsAny <Cargo>())); ICargoService cargoService = new CargoService(_cargoRepositoryMock.Object); var mensagens = cargoService.Atualizar(cargo.Mapear(), cargo.Id); _cargoRepositoryMock.Verify(mock => mock.Atualizar(It.IsAny <Cargo>()), Times.Once()); Assert.Equal(0, mensagens.Count); }
public void NaoDeveAtualizarCargoInvalido() { Cargo cargo = new Cargo(""); _cargoRepositoryMock = new Mock <ICargoRepository>(); _cargoRepositoryMock.Setup(mock => mock.Atualizar(It.IsAny <Cargo>())); ICargoService cargoService = new CargoService(_cargoRepositoryMock.Object); var mensagens = cargoService.Atualizar(cargo.Mapear(), cargo.Id); _cargoRepositoryMock.Verify(mock => mock.Atualizar(It.IsAny <Cargo>()), Times.Never()); Assert.Equal(1, mensagens.Count); Assert.Equal("Cargo invalido", mensagens[0]); }