public async Task Handle_PullRequestOpenedPayloadWithValidRepository_ProvisionsPullDogInstance()
        {
            //Arrange
            var databaseRepository = new PullDogRepository()
            {
                Handle          = "1337",
                PullDogSettings = new PullDogSettings()
            };

            var fakeMediator = Substitute.For <IMediator>();

            var handler = new PullRequestReadyPayloadHandler(fakeMediator);

            //Act
            await handler.HandleAsync(new WebhookPayloadContext(
                                          new WebhookPayload(),
                                          null !,
                                          databaseRepository,
                                          new PullDogPullRequest()
            {
                Handle = "1338"
            }));

            //Assert
            await fakeMediator
            .Received(1)
            .Send(Arg.Is <ProvisionPullDogEnvironmentCommand>(args =>
                                                              args.PullRequestHandle == "1338" &&
                                                              args.Repository == databaseRepository));
        }
        public async Task CanHandle_ActionReadyForReviewAndPullRequestStateOpen_ReturnsTrue()
        {
            //Arrange
            var fakeMediator = Substitute.For <IMediator>();

            var handler = new PullRequestReadyPayloadHandler(fakeMediator);

            //Act
            var result = handler.CanHandle(new WebhookPayload()
            {
                Action      = "ready_for_review",
                PullRequest = new PullRequestPayload()
                {
                    State = "open"
                }
            });

            //Assert
            Assert.IsTrue(result);
        }
        public async Task CanHandle_ActionOpenedAndPullRequestStateInvalid_ReturnsFalse()
        {
            //Arrange
            var fakeMediator = Substitute.For <IMediator>();

            var handler = new PullRequestReadyPayloadHandler(fakeMediator);

            //Act
            var result = handler.CanHandle(new WebhookPayload()
            {
                Action      = "opened",
                PullRequest = new PullRequestPayload()
                {
                    State = "invalid"
                }
            });

            //Assert
            Assert.IsFalse(result);
        }