public async Task HandleAsync(int id, IDeletePollOutputPort output)
        {
            Poll poll = await this.pollGateway.GetAsync(id);

            if (poll is null)
            {
                output.NotFound("Poll not found");
                this.loggerService.LogInformation("Cannot retrieve a poll with {@id}", id);
                return;
            }

            await this.pollGateway.DeleteAsync(poll);

            output.Success();
        }
Esempio n. 2
0
        public async Task HandleAsync_WhenPollExists_ShouldCallSuccess()
        {
            // Arrange
            const int pollId = 1;
            Poll      poll   = this.GetFakePoll();

            IPollGateway pollGatewayStub = A.Fake <IPollGateway>();

            A.CallTo(() => pollGatewayStub.GetAsync(pollId))
            .Returns(poll);

            IDeletePollOutputPort OutputPortMock = A.Fake <IDeletePollOutputPort>();

            var useCase = new DeletePollUseCase(null, pollGatewayStub);

            // Act
            await useCase.HandleAsync(pollId, OutputPortMock);

            // Assert
            A.CallTo(() => OutputPortMock.Success()).MustHaveHappenedOnceExactly();
        }