public async Task WebhookContentProcessorDeletePageLocationAsyncForCreateReturnsSuccess() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.OK; var exptectedGuidList = new List <Guid> { PageLocationIdForCreate, Guid.NewGuid() }; var expectedValidContentPageModel = BuildValidContentPageModel(); var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeContentCacheService.GetContentIdsContainingContentItemId(A <Guid> .Ignored)).Returns(exptectedGuidList); A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).Returns(expectedValidContentPageModel); A.CallTo(() => FakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).Returns(HttpStatusCode.OK); A.CallTo(() => FakeContentCacheService.RemoveContentItem(A <Guid> .Ignored, A <Guid> .Ignored)); // Act var result = await service.DeleteContentItemAsync(PageLocationIdForDelete).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentCacheService.GetContentIdsContainingContentItemId(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceOrMore(); A.CallTo(() => FakeEventMessageService.UpdateAsync(A <ContentPageModel> .Ignored)).MustHaveHappenedOnceOrMore(); A.CallTo(() => FakeEventMessageService.CreateAsync(A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeContentCacheService.RemoveContentItem(A <Guid> .Ignored, A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); Assert.Equal(expectedResponse, result); }
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); }
public async Task WebhookContentProcessorDeleteContentAsyncForCreateReturnsNoContent() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.NoContent; var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).Returns(expectedResponse); // Act var result = await service.DeleteContentAsync(SharedId).ConfigureAwait(false); // Assert A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); Assert.AreEqual(expectedResponse, result); }
public async Task WebhookContentProcessorDeleteContentItemAsyncForUpdateReturnsNoContent() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.NoContent; var exptectedEmptyGuidList = new List <Guid>(); var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeContentCacheService.GetContentIdsContainingContentItemId(A <Guid> .Ignored)).Returns(exptectedEmptyGuidList); // Act var result = await service.DeleteContentItemAsync(ContentItemIdForDelete).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentCacheService.GetContentIdsContainingContentItemId(A <Guid> .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(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeContentCacheService.RemoveContentItem(A <Guid> .Ignored, A <Guid> .Ignored)).MustNotHaveHappened(); Assert.Equal(expectedResponse, result); }
public async Task WebhookContentProcessorDeleteContentAsyncForCreateReturnsNoContent() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.NoContent; ContentPageModel? nullContentPageModel = null; var service = BuildWebhookContentProcessor(); A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).Returns(nullContentPageModel); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).Returns(expectedResponse); A.CallTo(() => FakeContentCacheService.Remove(A <Guid> .Ignored)); // Act var result = await service.DeleteContentAsync(ContentIdForDelete).ConfigureAwait(false); // Assert A.CallTo(() => FakeContentPageService.GetByIdAsync(A <Guid> .Ignored, A <string> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeEventGridService.SendEventAsync(A <WebhookCacheOperation> .Ignored, A <ContentPageModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeContentCacheService.Remove(A <Guid> .Ignored)).MustNotHaveHappened(); Assert.Equal(expectedResponse, result); }
public async Task WebhookContentProcessorProcessContentAsyncForUpdateReturnsNoContent() { // Arrange const HttpStatusCode expectedResponse = HttpStatusCode.NoContent; var expectedValidApiContentModel = BuildValidCmsApiSharedContentModel(); ContentPageModel?expectedValidContentPageModel = default; var url = new Uri("https://somewhere.com"); var service = BuildWebhookContentProcessor(); CmsApiSharedContentModel content; A.CallTo(() => FakeCmsApiService.GetItemAsync <CmsApiSharedContentModel>(A <Uri> .Ignored)).Returns(Task.FromResult <CmsApiSharedContentModel>(null)); // Act var result = await service.ProcessContentAsync(url, SharedId).ConfigureAwait(false); // Assert A.CallTo(() => FakeCmsApiService.GetItemAsync <CmsApiSharedContentModel>(A <Uri> .Ignored)).MustHaveHappenedOnceExactly(); A.CallTo(() => FakeEventMessageService.UpdateAsync(A <CmsApiSharedContentModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.CreateAsync(A <CmsApiSharedContentModel> .Ignored)).MustNotHaveHappened(); A.CallTo(() => FakeEventMessageService.DeleteAsync(A <Guid> .Ignored)).MustNotHaveHappened(); Assert.AreEqual(expectedResponse, result); }