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

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

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

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

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

            bool success = await SyncOrchestrator.Publish(ContentItem);

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

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

            await SyncOrchestrator.Publish(ContentItem);

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

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

            await SyncOrchestrator.Publish(ContentItem);

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