public async Task HandleAsync_WithInvalidPoll_ShouldCallError() { // Arrange ILoggerService <CreatePollUseCase> loggerServiceStub = A.Fake <ILoggerService <CreatePollUseCase> >(); ICreatePollOutputPort OutputPortMock = A.Fake <ICreatePollOutputPort>(); var useCase = new CreatePollUseCase(loggerServiceStub, null, null); CreatePollInput input = GetInvalidCreatePollInput(); // Act await useCase.HandleAsync(input, OutputPortMock); // Assert A.CallTo(() => OutputPortMock.Error( A <string> .That.IsNotNull())) .MustHaveHappenedOnceExactly(); }
public async Task HandleAsync(CreatePollInput input, ICreatePollOutputPort output) { try { var poll = new Poll(input.Title, input.Note, input.SingleOptionLimitation, input.DueDate); foreach (string option in input.Options) { poll.AddOption(option); } await this.pollGateway.CreateAsync(poll); await this.emailSender.SendAsync("SUBJECT", "PLAIN_TEXT_CONTENT", input.ParticipantEmailAddresses); output.Success(new CreatePollOutput(poll.Id)); } catch (DomainException ex) { this.loggerService.LogInformation("{@excepton} occured when trying to create a poll with {@input}", ex, input); output.Error(ex.Message); } }