public void AndProviderIdIsNotProvidedThenValidationFails() { var command = new CreateAgreementEventCommand { ContractType = "MainProvider", Event = "ABC" }; Assert.ThrowsAsync <ValidationException>(() => Handler.Handle(command)); }
public async Task ThenTheEventIsCreated() { var command = new CreateAgreementEventCommand { ContractType = "MainProvider", Event = "Some Event", ProviderId = "ZZZ999" }; await Handler.Handle(command); EventsLogger.Verify(x => x.Info($"Received message {command.Event}", null, command.ProviderId, command.Event), Times.Once); Repository.Verify(x => x.Create(It.Is <AgreementEvent>(e => e.ContractType == command.ContractType && e.Event == command.Event && e.ProviderId == command.ProviderId))); EventsLogger.Verify(x => x.Info($"Finished processing message {command.Event}", null, null, null), Times.Once); }
public void AndTheEventCreationFailsThenTheExceptionIsLogged() { var command = new CreateAgreementEventCommand { ContractType = "MainProvider", Event = "Some Event", ProviderId = "ZZZ999" }; var expectedException = new Exception("Test"); Repository.Setup(x => x.Create(It.Is <AgreementEvent>(e => e.ContractType == command.ContractType && e.Event == command.Event && e.ProviderId == command.ProviderId))).Throws(expectedException); Assert.ThrowsAsync <Exception>(() => Handler.Handle(command)); EventsLogger.Verify(x => x.Error(expectedException, $"Error processing message {command.Event} - {expectedException.Message}", null, command.ProviderId, command.Event), Times.Once); }