Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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]);
        }