public async Task Update_PublishedSyncToGraphReplicaSetThrows_ExceptionPropagates()
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(AllowSyncResult.Allowed);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(AllowSyncResult.Allowed);

            A.CallTo(() => PublishedMergeGraphSyncer.SyncToGraphReplicaSet())
            .Throws(() => new Exception());

            await Assert.ThrowsAsync <Exception>(() => SyncOrchestrator.Update(ContentItem, ContentItem));
        }
        public async Task Update_SyncAllowedSyncMatrix_ReturnsBool(
            AllowSyncResult publishedAllowSyncAllowedResult,
            AllowSyncResult previewAllowSyncAllowedResult,
            bool expectedSuccess)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncAllowedResult);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncAllowedResult);

            bool success = await SyncOrchestrator.Update(ContentItem, ContentItem);

            Assert.Equal(expectedSuccess, success);
        }
        public async Task Update_SyncToGraphReplicaSetOnPublishedGraphCalled(
            AllowSyncResult publishedAllowSyncResult,
            AllowSyncResult previewAllowSyncResult,
            int publishedCalled)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncResult);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncResult);

            await SyncOrchestrator.Update(ContentItem, ContentItem);

            A.CallTo(() => PublishedMergeGraphSyncer.SyncToGraphReplicaSet())
            .MustHaveHappened(publishedCalled, Times.Exactly);
        }
        public async Task Update_EventGridPublishingHandlerCalled(
            AllowSyncResult publishedAllowSyncResult,
            AllowSyncResult previewAllowSyncResult,
            int publishedCalled,
            int draftSavedCalled)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncResult);

            A.CallTo(() => PreviewAllowSync.Result)
            .Returns(previewAllowSyncResult);

            await SyncOrchestrator.Update(ContentItem, ContentItem);

            A.CallTo(() => EventGridPublishingHandler.Published(
                         A <IOrchestrationContext> .That.Matches(ctx => Equals(ctx.ContentItem, ContentItem))))
            .MustHaveHappened(publishedCalled, Times.Exactly);
            A.CallTo(() => EventGridPublishingHandler.DraftSaved(
                         A <IOrchestrationContext> .That.Matches(ctx => Equals(ctx.ContentItem, ContentItem))))
            .MustHaveHappened(draftSavedCalled, Times.Exactly);
        }