public void WebhooksServiceProcessMessageAsyncContentThrowsErrorForInvalidUrl()
        {
            // Arrange
            const ContentCacheStatus isContentItem = ContentCacheStatus.ContentItem;
            var url     = "/somewhere.com";
            var service = BuildWebhooksService();


            // Act
            Assert.ThrowsAsync <InvalidDataException>(() => service.ProcessMessageAsync(WebhookCacheOperation.CreateOrUpdate, Guid.NewGuid(), SharedId, url));
            // Assert
            A.CallTo(() => FakeWebhookContentProcessor.DeleteContentAsync(A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeWebhookContentProcessor.ProcessContentAsync(A <Uri> .Ignored, A <Guid> .Ignored)).MustNotHaveHappened();
        }
        public async Task WebhooksServiceProcessMessageAsyncNoneOptionReturnsBadRequest()
        {
            // Arrange
            const HttpStatusCode expectedResponse = HttpStatusCode.BadRequest;
            var url     = "https://somewhere.com";
            var service = BuildWebhooksService();


            // Act
            var result = await service.ProcessMessageAsync(WebhookCacheOperation.None, Guid.NewGuid(), SharedId, url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeWebhookContentProcessor.DeleteContentAsync(A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeWebhookContentProcessor.ProcessContentAsync(A <Uri> .Ignored, A <Guid> .Ignored)).MustNotHaveHappened();

            Assert.AreEqual(expectedResponse, result);
        }
        public async Task WebhooksServiceProcessMessageAsyncContentThrowsErrorForInvalidUrl()
        {
            // Arrange
            const ContentCacheStatus isContentItem = ContentCacheStatus.ContentItem;
            var url     = "/somewhere.com";
            var service = BuildWebhooksService();

            A.CallTo(() => FakeContentCacheService.CheckIsContentItem(A <Guid> .Ignored)).Returns(isContentItem);

            // Act
            await Assert.ThrowsAsync <InvalidDataException>(async() => await service.ProcessMessageAsync(WebhookCacheOperation.CreateOrUpdate, Guid.NewGuid(), ContentIdForCreate, url).ConfigureAwait(false)).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeContentCacheService.CheckIsContentItem(A <Guid> .Ignored)).MustHaveHappenedOnceExactly();
            A.CallTo(() => FakeWebhookContentProcessor.DeleteContentItemAsync(A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeWebhookContentProcessor.DeleteContentAsync(A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeWebhookContentProcessor.ProcessContentItemAsync(A <Uri> .Ignored, A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeWebhookContentProcessor.ProcessContentAsync(A <Uri> .Ignored, A <Guid> .Ignored)).MustNotHaveHappened();
        }
        public async Task WebhooksServiceProcessMessageAsyncContentCreateReturnsSuccess()
        {
            // Arrange
            const ContentCacheStatus isContentItem    = ContentCacheStatus.Content;
            const HttpStatusCode     expectedResponse = HttpStatusCode.Created;
            var url     = "https://somewhere.com";
            var service = BuildWebhooksService();

            A.CallTo(() => FakeWebhookContentProcessor.ProcessContentAsync(A <Uri> .Ignored, A <Guid> .Ignored)).Returns(expectedResponse);

            // Act
            var result = await service.ProcessMessageAsync(WebhookCacheOperation.CreateOrUpdate, Guid.NewGuid(), SharedId, url).ConfigureAwait(false);

            // Assert
            A.CallTo(() => FakeWebhookContentProcessor.DeleteContentAsync(A <Guid> .Ignored)).MustNotHaveHappened();
            A.CallTo(() => FakeWebhookContentProcessor.ProcessContentAsync(A <Uri> .Ignored, A <Guid> .Ignored)).MustHaveHappenedOnceExactly();

            Assert.AreEqual(expectedResponse, result);
        }