예제 #1
0
        public async Task DeleteDraft_EventGridPublishingHandlerCalled()
        {
            await DeleteOrchestrator.Unpublish(ContentItem);

            A.CallTo(() => EventGridPublishingHandler.Unpublished(
                         A <IOrchestrationContext> .That.Matches(ctx => Equals(ctx.ContentItem, ContentItem))))
            .MustHaveHappened();
        }
예제 #2
0
        public Task DeleteDraft_MergeGraphSyncerThrows_ExceptionPropagates()
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(AllowSyncResult.Allowed);

            A.CallTo(() => PublishedDeleteGraphSyncer.Delete())
            .Throws(() => new Exception());

            return(Assert.ThrowsAsync <Exception>(() => DeleteOrchestrator.Unpublish(ContentItem)));
        }
        public async Task Publish_EventGridPublishingHandlerCalled()
        {
            bool success = await DeleteOrchestrator.Delete(ContentItem);

            Assert.True(success);

            A.CallTo(() => EventGridPublishingHandler.Deleted(
                         A <IOrchestrationContext> .That.Matches(ctx => Equals(ctx.ContentItem, ContentItem))))
            .MustHaveHappened();
        }
예제 #4
0
        public async Task DeleteDraft_SyncAllowedMatrix_ReturnsBool(
            AllowSyncResult allowSyncAllowedResult,
            bool expectedSuccess)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(allowSyncAllowedResult);

            bool success = await DeleteOrchestrator.Unpublish(ContentItem);

            Assert.Equal(expectedSuccess, success);
        }
예제 #5
0
        public async Task DeleteDraft_SyncAllowedMatrix_SyncCalled(
            AllowSyncResult allowSyncAllowedResult,
            bool expectedSyncCalled)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(allowSyncAllowedResult);

            await DeleteOrchestrator.Unpublish(ContentItem);

            A.CallTo(() => PublishedDeleteGraphSyncer.Delete())
            .MustHaveHappened(expectedSyncCalled?1:0, Times.Exactly);
        }
        public async Task Delete_SyncAllowedSyncMatrix_ReturnsBool(
            AllowSyncResult publishedAllowSyncAllowedResult,
            AllowSyncResult previewAllowSyncAllowedResult,
            bool expectedSuccess)
        {
            A.CallTo(() => PublishedAllowSync.Result)
            .Returns(publishedAllowSyncAllowedResult);

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

            bool success = await DeleteOrchestrator.Delete(ContentItem);

            Assert.Equal(expectedSuccess, success);
        }
        protected DeleteOrchestratorTestsBase()
        {
            ContentDefinitionManager = A.Fake <IContentDefinitionManager>();
            Notifier = A.Fake <GraphSyncNotifier>();

            PublishedContentItemVersion = A.Fake <IPublishedContentItemVersion>();
            A.CallTo(() => PublishedContentItemVersion.GraphReplicaSetName)
            .Returns(GraphReplicaSetNames.Published);

            PreviewContentItemVersion = A.Fake <IPreviewContentItemVersion>();
            A.CallTo(() => PreviewContentItemVersion.GraphReplicaSetName)
            .Returns(GraphReplicaSetNames.Preview);

            ServiceProvider = A.Fake <IServiceProvider>();
            Logger          = A.Fake <ILogger <DeleteOrchestrator> >();

            ContentItem = new ContentItem();

            ContentManager = A.Fake <IContentManager>();
            A.CallTo(() => ServiceProvider.GetService(A <Type> .That.Matches(
                                                          t => t.Name == nameof(IContentManager))))
            .Returns(ContentManager);

            PreviewDeleteGraphSyncer   = A.Fake <IDeleteGraphSyncer>();
            PublishedDeleteGraphSyncer = A.Fake <IDeleteGraphSyncer>();

            PreviewAllowSync = A.Fake <IAllowSync>();
            A.CallTo(() => PreviewDeleteGraphSyncer.DeleteAllowed(
                         A <ContentItem> ._,
                         A <IContentItemVersion> .That.Matches(v => v.GraphReplicaSetName == GraphReplicaSetNames.Preview),
                         SyncOperation,
                         null,
                         null))
            .Returns(PreviewAllowSync);

            PublishedAllowSync = A.Fake <IAllowSync>();
            A.CallTo(() => PublishedDeleteGraphSyncer.DeleteAllowed(
                         A <ContentItem> ._,
                         A <IContentItemVersion> .That.Matches(v => v.GraphReplicaSetName == GraphReplicaSetNames.Published),
                         SyncOperation,
                         null,
                         null))
            .Returns(PublishedAllowSync);

            EventGridPublishingHandler = A.Fake <IContentOrchestrationHandler>();
            A.CallTo(() => EventGridPublishingHandler.Published(A <IOrchestrationContext> .Ignored)).Returns(Task.CompletedTask);
            A.CallTo(() => EventGridPublishingHandler.DraftSaved(A <IOrchestrationContext> .Ignored)).Returns(Task.CompletedTask);
            A.CallTo(() => EventGridPublishingHandler.Cloned(A <IOrchestrationContext> .Ignored)).Returns(Task.CompletedTask);
            A.CallTo(() => EventGridPublishingHandler.Unpublished(A <IOrchestrationContext> .Ignored)).Returns(Task.CompletedTask);
            A.CallTo(() => EventGridPublishingHandler.DraftDiscarded(A <IOrchestrationContext> .Ignored)).Returns(Task.CompletedTask);
            A.CallTo(() => EventGridPublishingHandler.Deleted(A <IOrchestrationContext> .Ignored)).Returns(Task.CompletedTask);

            DeleteOrchestrator = new DeleteOrchestrator(
                ContentDefinitionManager,
                Notifier,
                ServiceProvider,
                Logger,
                PublishedContentItemVersion,
                PreviewContentItemVersion,
                new List <IContentOrchestrationHandler> {
                EventGridPublishingHandler
            });

            TestActivity = new Activity("UnitTest").Start();
        }