public async Task PagesWebhookServiceProcessMessageCreateOrUpdateOperationReturnsOk()
        {
            // Arrange
            var serviceToTest = new PagesWebhookService(pageDataLoadService, logger);

            A.CallTo(() => pageDataLoadService.CreateOrUpdateAsync(A <Guid> .Ignored)).Returns(HttpStatusCode.OK);

            // Act
            var result = await serviceToTest.ProcessMessageAsync(Compui.Subscriptions.Pkg.Data.Enums.WebhookCacheOperation.CreateOrUpdate, Guid.NewGuid(), Guid.NewGuid(), new Uri("http://somewhere.com")).ConfigureAwait(false);

            // Assert
            Assert.Equal(HttpStatusCode.OK, result);
        }
Exemplo n.º 2
0
        public async Task <HttpStatusCode> ProcessMessageAsync(WebhookCacheOperation webhookCacheOperation, Guid eventId, Guid contentId, Uri url)
        {
            logger.LogInformation($"{nameof(ProcessMessageAsync)} called in {nameof(PagesWebhookService)}");

            switch (webhookCacheOperation)
            {
            case WebhookCacheOperation.CreateOrUpdate:
                logger.LogInformation($"{nameof(WebhookCacheOperation.CreateOrUpdate)} called in {nameof(PagesWebhookService)}  with Content Id {contentId}");
                return(await pagesDataLoadService.CreateOrUpdateAsync(contentId).ConfigureAwait(false));

            case WebhookCacheOperation.Delete:
                logger.LogInformation($"{nameof(WebhookCacheOperation.Delete)} called in {nameof(PagesWebhookService)} with Content Id {contentId}");
                return(await pagesDataLoadService.RemoveAsync(contentId).ConfigureAwait(false));

            default:
                return(HttpStatusCode.OK);
            }
        }