public async Task Inserir_Cargo_Invalido(string descricao) { var builder = new CargoBuilder().WithDescricao(descricao); var entity = builder.Build(); var dto = builder.BuildDto(); await _armazenadorDeCargo.Armazenar(dto); _cargoRepositoryMock.Verify(r => r.Add(entity), Times.Never); Assert.True(_notificationContext.HasNotifications); entity.ValidationResult.Errors.Should().HaveCount(1); }
public async Task Inserir_Cargo_Valido() { var builder = new CargoBuilder(); var entity = builder.Build(); var dto = builder.BuildDto(); await _armazenadorDeCargo.Armazenar(dto); _cargoRepositoryMock.Verify(r => r.Add(It.Is <Cargo>(cargo => cargo.Descricao == dto.Descricao)), Times.Once); Assert.False(_notificationContext.HasNotifications); }
public async Task Alterar_Cargo_Inexistente() { var builder = new CargoBuilder().WithId(10); var entity = builder.Build(); var dto = builder.BuildDto(); _cargoRepositoryMock .Setup(c => c.Get(It.IsAny <Predicate <Cargo> >())) .ReturnsAsync(new List <Cargo> { }); await _armazenadorDeCargo.Armazenar(dto); _cargoRepositoryMock.Verify(r => r.Update(entity), Times.Never); Assert.True(_notificationContext.HasNotifications); _notificationContext.Notifications.Should().HaveCount(1); }
public async Task Alterar_Cargo_Sucesso() { var builder = new CargoBuilder().WithId(1); var entityAlteracao = builder.Build(); var dto = builder.BuildDto(); _cargoRepositoryMock .Setup(c => c.Get(It.IsAny <Predicate <Cargo> >())) .ReturnsAsync(new List <Cargo> { entityAlteracao }); await _armazenadorDeCargo.Armazenar(dto); _cargoRepositoryMock.Verify(r => r.Update(entityAlteracao), Times.Once); Assert.False(_notificationContext.HasNotifications); }
public async Task Alterar_Cargo_Descricao_Invalida(string descricao) { var builder = new CargoBuilder() .WithDescricao(descricao) .WithId(1); var entity = new Cargo(descricao); var dto = builder.BuildDto(); _cargoRepositoryMock .Setup(c => c.Get(It.IsAny <Predicate <Cargo> >())) .ReturnsAsync(new List <Cargo> { entity }); await _armazenadorDeCargo.Armazenar(dto); _cargoRepositoryMock.Verify(r => r.Update(entity), Times.Never); Assert.True(_notificationContext.HasNotifications); entity.ValidationResult.Errors.Should().HaveCount(1); }