예제 #1
0
        public async Task DeleteListener(Boolean mediatorResult)
        {
            Random random     = new Random();
            Guid   pipelineId = random.NextGuid();

            Mock <IMediator> mediatorMock = new Mock <IMediator>(MockBehavior.Strict);

            mediatorMock.Setup(x => x.Send(It.Is <DeleteNotificationPipelineCommand>(y =>
                                                                                     y.PipelineId == pipelineId
                                                                                     ), It.IsAny <CancellationToken>())).ReturnsAsync(mediatorResult).Verifiable();

            var controller = new NotificationsController(
                Mock.Of <INotificationEngine>(MockBehavior.Strict), mediatorMock.Object,
                Mock.Of <ILogger <NotificationsController> >());

            var actionResult = await controller.DeletePipeline(pipelineId);

            if (mediatorResult == true)
            {
                actionResult.EnsureNoContentResult();
            }
            else
            {
                actionResult.EnsureBadRequestObjectResult("unable to delete the pipeline");
            }

            mediatorMock.Verify();
        }