public GraphSyncPartGraphSyncerValidateSyncComponentTestsBase()
        {
            A.CallTo(() => SyncNameProvider.ContentIdPropertyName).Returns(ContentIdPropertyName);
            A.CallTo(() => SyncNameProvider.IdPropertyName()).Returns(NodeTitlePropertyName);

            ContentPartGraphSyncer = new GraphSyncPartGraphSyncer();
        }
        public FieldGraphSyncer_AddSyncComponentsTestsBase()
        {
            MergeNodeCommand = A.Fake <IMergeNodeCommand>();
            //todo: best way to do this?
            MergeNodeCommand.Properties = new Dictionary <string, object>();

            ReplaceRelationshipsCommand = A.Fake <IReplaceRelationshipsCommand>();

            ContentPartFieldDefinition = A.Fake <IContentPartFieldDefinition>();
            A.CallTo(() => ContentPartFieldDefinition.Name).Returns(_fieldName);

            ContentTypePartDefinition = A.Fake <ContentTypePartDefinition>();

            SyncNameProvider = A.Fake <ISyncNameProvider>();
            A.CallTo(() => SyncNameProvider.PropertyName(_fieldName)).Returns(_fieldName);

            GraphReplicaSet = A.Fake <IGraphReplicaSet>();

            //todo: this isn't going to work!
            ContentItem        = A.Fake <ContentItem>();
            ContentManager     = A.Fake <IContentManager>();
            ContentItemVersion = A.Fake <IContentItemVersion>();

            GraphMergeContext = A.Fake <IGraphMergeContext>();
            A.CallTo(() => GraphMergeContext.SyncNameProvider).Returns(SyncNameProvider);
            A.CallTo(() => GraphMergeContext.GraphReplicaSet).Returns(GraphReplicaSet);
            A.CallTo(() => GraphMergeContext.MergeNodeCommand).Returns(MergeNodeCommand);
            A.CallTo(() => GraphMergeContext.ReplaceRelationshipsCommand).Returns(ReplaceRelationshipsCommand);
            A.CallTo(() => GraphMergeContext.ContentItem).Returns(ContentItem);
            A.CallTo(() => GraphMergeContext.ContentManager).Returns(ContentManager);
            A.CallTo(() => GraphMergeContext.ContentItemVersion).Returns(ContentItemVersion);
            A.CallTo(() => GraphMergeContext.ContentTypePartDefinition).Returns(ContentTypePartDefinition);
            A.CallTo(() => GraphMergeContext.ContentPartFieldDefinition).Returns(ContentPartFieldDefinition);
        }
示例#3
0
        public SitemapPartGraphSyncerAddSyncComponentsTestsBase()
        {
            A.CallTo(() => SyncNameProvider.PropertyName("OverrideSitemapConfig")).Returns("sitemap_OverrideSitemapConfig");
            A.CallTo(() => SyncNameProvider.PropertyName("ChangeFrequency")).Returns("sitemap_ChangeFrequency");
            A.CallTo(() => SyncNameProvider.PropertyName("Priority")).Returns("sitemap_Priority");
            A.CallTo(() => SyncNameProvider.PropertyName("Exclude")).Returns("sitemap_Exclude");

            ContentPartGraphSyncer = new SitemapPartGraphSyncer();
        }
示例#4
0
        public async Task AddSyncComponents_NullHtmlInContent_TitleNotAddedToMergeNodeCommandsProperties()
        {
            A.CallTo(() => SyncNameProvider.PropertyName("Html")).Returns("htmlbody_Html");

            Content = JObject.Parse("{\"Html\": null}");

            await CallAddSyncComponents();

            IDictionary <string, object> expectedProperties = new Dictionary <string, object>();

            Assert.Equal(expectedProperties, MergeNodeCommand.Properties);
        }
        public async Task AddSyncComponents_NullScheduledPublicUtcInContent_TitleNotAddedToMergeNodeCommandsProperties()
        {
            A.CallTo(() => SyncNameProvider.PropertyName("ScheduledPublishUtc")).Returns("publishlater_ScheduledPublishUtc");

            Content = JObject.Parse("{\"ScheduledPublishUtc\": null}");

            await CallAddSyncComponents();

            IDictionary <string, object> expectedProperties = new Dictionary <string, object>();

            Assert.Equal(expectedProperties, MergeNodeCommand.Properties);
        }
        public async Task ValidateSyncComponentTests(bool expected, bool stringContentPropertyMatchesNodePropertyReturns)
        {
            A.CallTo(() => GraphValidationHelper.DateTimeContentPropertyMatchesNodeProperty(
                         ContentKey,
                         A <JObject> ._,
                         NodeTitlePropertyName,
                         SourceNode)).Returns((stringContentPropertyMatchesNodePropertyReturns, ""));
            A.CallTo(() => SyncNameProvider.PropertyName("ScheduledPublishUtc")).Returns("publishlater_ScheduledPublishUtc");

            (bool validated, _) = await CallValidateSyncComponent();

            Assert.Equal(expected, validated);
        }
示例#7
0
        public async Task AddSyncComponents_HtmlInContent_TitleAddedToMergeNodeCommandsProperties()
        {
            A.CallTo(() => SyncNameProvider.PropertyName("Html")).Returns("htmlbody_Html");

            const string html = "<p>A test paragraph</p>";

            Content = JObject.Parse($"{{\"Html\": \"{html}\"}}");

            await CallAddSyncComponents();

            IDictionary <string, object> expectedProperties = new Dictionary <string, object>
            {
                { "htmlbody_Html", html }
            };

            Assert.Equal(expectedProperties, MergeNodeCommand.Properties);
        }
        public async Task AddSyncComponents_ScheduledPublishUtcContent_TitleAddedToMergeNodeCommandsProperties()
        {
            A.CallTo(() => SyncNameProvider.PropertyName("ScheduledPublishUtc")).Returns("publishlater_ScheduledPublishUtc");

            const string scheduledDateUtc = "2020-06-28T09:58:00Z";
            DateTime     expectedDateUtc  = new DateTime(2020, 6, 28, 9, 58, 0, DateTimeKind.Utc);

            Content = JObject.Parse($"{{\"ScheduledPublishUtc\": \"{scheduledDateUtc}\"}}");

            await CallAddSyncComponents();

            IDictionary <string, object> expectedProperties = new Dictionary <string, object>
            {
                { "publishlater_ScheduledPublishUtc", expectedDateUtc }
            };

            Assert.Equal(expectedProperties, MergeNodeCommand.Properties);
        }
示例#9
0
        public SyncNameProviderHelperTests()
        {
            SyncNameProviderCSharpScriptGlobals = A.Fake <ISyncNameProviderCSharpScriptGlobals>();

            ContentDefinitionManager = A.Fake <IContentDefinitionManager>();
            ContentTypeDefinition    = new ContentTypeDefinition("name", "displayName",
                                                                 new []
            {
                new ContentTypePartDefinition(nameof(GraphSyncPart), new ContentPartDefinition(nameof(GraphSyncPart)), null)
            },
                                                                 new JObject());
            A.CallTo(() => ContentDefinitionManager.GetTypeDefinition(_contentType)).Returns(ContentTypeDefinition);

            SuperpositionContentItemVersion = A.Fake <ISuperpositionContentItemVersion>();

            SyncNameProvider = new SyncNameProvider(
                SyncNameProviderCSharpScriptGlobals,
                ContentDefinitionManager,
                SuperpositionContentItemVersion);
        }
示例#10
0
        public EventGridPublishingHandlerTests()
        {
            EventGridConfigurationOptionsMonitor = A.Fake <IOptionsMonitor <EventGridConfiguration> >();

            EventGridConfiguration = new EventGridConfiguration();
            A.CallTo(() => EventGridConfigurationOptionsMonitor.CurrentValue)
            .Returns(EventGridConfiguration);

            EventGridContentClient = A.Fake <IEventGridContentClient>();

            SyncNameProvider = A.Fake <ISyncNameProvider>();
            UserId           = "C7FE81FB-CF2B-4897-ABE9-1EB931A31371";
            A.CallTo(() => SyncNameProvider.GetEventIdPropertyValue(
                         A <JObject> ._,
                         A <IContentItemVersion> ._)).Returns(UserId);

            PublishedContentItemVersion    = A.Fake <IPublishedContentItemVersion>();
            PreviewContentItemVersion      = A.Fake <IPreviewContentItemVersion>();
            NeutralEventContentItemVersion = A.Fake <INeutralEventContentItemVersion>();
            Logger = A.Fake <ILogger <EventGridPublishingHandler> >();

            EventGridPublishingHandler = new EventGridPublishingHandler(
                EventGridConfigurationOptionsMonitor,
                EventGridContentClient,
                SyncNameProvider,
                PublishedContentItemVersion,
                PreviewContentItemVersion,
                NeutralEventContentItemVersion,
                Logger);

            OrchestrationContext = A.Fake <IOrchestrationContext>();
            ContentItem          = new ContentItem
            {
                ContentType          = "ContentType",
                ContentItemVersionId = "ContentItemVersionId",
                DisplayText          = "DisplayText",
                Author = "Author"
            };
            A.CallTo(() => OrchestrationContext.ContentItem)
            .Returns(ContentItem);
        }
示例#11
0
        public FieldGraphSyncer_ValidateSyncComponentTestsBase()
        {
            ContentItemField = JObject.Parse("{}");

            ContentTypePartDefinition = A.Fake <ContentTypePartDefinition>();

            ContentPartFieldDefinition = A.Fake <IContentPartFieldDefinition>();
            A.CallTo(() => ContentPartFieldDefinition.Name).Returns(FieldNameBase);

            ContentManager = A.Fake <IContentManager>();

            SourceNode            = A.Fake <INode>();
            NodeWithRelationships = A.Fake <ISubgraph>();
            A.CallTo(() => NodeWithRelationships.SourceNode).Returns(SourceNode);

            SyncNameProvider = A.Fake <ISyncNameProvider>();
            A.CallTo(() => SyncNameProvider.PropertyName(FieldNameBase)).Returns(FieldNameTransformed);

            GraphValidationHelper = A.Fake <IGraphValidationHelper>();

            ExpectedRelationshipCounts = new Dictionary <string, int>();

            ContentItemVersion = A.Fake <IContentItemVersion>();

            ValidateAndRepairGraph = A.Fake <IValidateAndRepairGraph>();

            ValidateAndRepairContext = A.Fake <IValidateAndRepairContext>();
            A.CallTo(() => ValidateAndRepairContext.SyncNameProvider).Returns(SyncNameProvider);
            A.CallTo(() => ValidateAndRepairContext.ContentManager).Returns(ContentManager);
            A.CallTo(() => ValidateAndRepairContext.ContentItemVersion).Returns(ContentItemVersion);
            A.CallTo(() => ValidateAndRepairContext.ContentTypePartDefinition).Returns(ContentTypePartDefinition);
            A.CallTo(() => ValidateAndRepairContext.ContentPartFieldDefinition).Returns(ContentPartFieldDefinition);
            A.CallTo(() => ValidateAndRepairContext.NodeWithRelationships).Returns(NodeWithRelationships);
            A.CallTo(() => ValidateAndRepairContext.GraphValidationHelper).Returns(GraphValidationHelper);
            A.CallTo(() => ValidateAndRepairContext.ExpectedRelationshipCounts).Returns(ExpectedRelationshipCounts);
            A.CallTo(() => ValidateAndRepairContext.ValidateAndRepairGraph).Returns(ValidateAndRepairGraph);
        }