public async Task WebhookContentProcessorProcessContentAsyncForUpdateReturnsNoContent() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.NoContent; var expectedValidApiContentModel = BuildValidPagesApiContentModel(); ContentPageModel?expectedValidContentPageModel = default; var url = new Uri("https://somewhere.com"); var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeCmsApiService.GetItemAsync <CmsApiDataModel>(A <Uri> .Ignored)).Returns(expectedValidApiContentModel); A.CallTo(() => FakeMapper.Map <ContentPageModel?>(A <CmsApiDataModel> .Ignored)).Returns(expectedValidContentPageModel); // Act var result = await service.ProcessContentAsync(url, ContentIdForCreate).ConfigureAwait(false); // Assert A.CallTo(() => FakeCmsApiService.GetItemAsync <CmsApiDataModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeMapper.Map <ContentPageModel>(A <CmsApiDataModel> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.CreateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventGridService.CompareAndSendEventAsync(A <ContentPageModel> .Ignored, A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened(); Assert.Equal(expectedResponse, result); }
public async Task WebhookContentProcessorProcessContentItemAsyncReturnsNoContentWhenNoContentIds() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.NoContent; var exptectedEmptyGuidList = new List <Guid>(); var url = new Uri("https://somewhere.com"); var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeContentCacheService.GetContentIdsContainingContentItemId(A <Guid> .Ignored)).Returns(exptectedEmptyGuidList); // Act var result = await service.ProcessContentItemAsync(url, ContentItemIdForUpdate).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentCacheService.GetContentIdsContainingContentItemId(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakePageLocatonUpdater.FindAndUpdateAsync(A <Uri> .Ignored, A <Guid> .Ignored, A <List <PageLocationModel> > .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeContentItemUpdater.FindAndUpdateAsync(A <Uri> .Ignored, A <Guid> .Ignored, A <List <ContentItemModel> > .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.CreateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventGridService.CompareAndSendEventAsync(A <ContentPageModel> .Ignored, A <ContentPageModel> .Ignored)).MustNotHaveHappened(); Assert.Equal(expectedResponse, result); }