public async Task Handle_CallsRepository() { var command = new CreateUpdateClientCommand(new ConfigurationClientPayload { ClientId = clientId, Name = "Test Client", Description = "Description", Enviroment = "Dev", Group = "3E37AC18-A00F-47A5-B84E-C79E0823F6D3", Settings = new List <ConfigurationClientSetting> { new ConfigurationClientSetting { Key = "Password", Value = "1234" } } }); ConfigurationClient observed = null; configurationClientRepository.Setup(r => r.UpdateClientAsync(It.IsAny <ConfigurationClient>())) .Callback((ConfigurationClient arg) => observed = arg) .Returns(() => Task.FromResult(true)); await target.Handle(command); Assert.NotNull(observed); AssertClient(command.Client, observed); }
public async Task Handle_ReturnsFailedIfClientNull() { var command = new CreateUpdateClientCommand(null); var result = await target.Handle(command); Assert.NotNull(result); Assert.False(result.IsSuccessful); }
public async Task Handle_CallsEventService() { var command = new CreateUpdateClientCommand(new ConfigurationClientPayload { ClientId = clientId, }); await target.Handle(command); eventService.Verify(r => r.Publish(It.Is <ConfigurationClientUpdatedEvent>(e => e.ClientId == clientId))); }
public async Task Handle_CallsRepository_WithPopulatedIdIfEmpty() { var command = new CreateUpdateClientCommand(new ConfigurationClientPayload { ClientId = string.Empty, }); await target.Handle(command); configurationClientRepository.Verify(r => r.UpdateClientAsync(It.Is <ConfigurationClient>(g => !string.IsNullOrWhiteSpace(g.ClientId)))); }
public async Task Handle_ReturnsSuccess() { var command = new CreateUpdateClientCommand(new ConfigurationClientPayload { ClientId = clientId, }); var result = await target.Handle(command); Assert.NotNull(result); Assert.True(result.IsSuccessful); }