Example #1
0
        public void DocumentOnProcessInlinesBegin_DoesNotReplaceExistingLinkReferenceDefinitions()
        {
            // Arrange
            const string     dummyLinkLabelContent = "dummyLinkLabelContent";
            InlineProcessor  dummyInlineProcessor  = MarkdigTypesFactory.CreateInlineProcessor();
            FlexiFigureBlock dummyFlexiFigureBlock = CreateFlexiFigureBlock(linkLabelContent: dummyLinkLabelContent);

            dummyInlineProcessor.Document.SetData(FlexiFigureBlockFactory.REFERENCE_LINKABLE_FLEXI_FIGURE_BLOCKS_KEY,
                                                  new List <FlexiFigureBlock> {
                dummyFlexiFigureBlock
            });
            var dummyLinkReferenceDefinition = new LinkReferenceDefinition();

            dummyInlineProcessor.Document.SetLinkReferenceDefinition(dummyLinkLabelContent, dummyLinkReferenceDefinition);
            FlexiFigureBlockFactory testSubject = CreateFlexiFigureBlockFactory();

            // Act
            testSubject.DocumentOnProcessInlinesBegin(dummyInlineProcessor, null);

            // Assert
            Dictionary <string, LinkReferenceDefinition> linkReferenceDefinitions =
                (dummyInlineProcessor.Document.GetData(typeof(LinkReferenceDefinitionGroup)) as LinkReferenceDefinitionGroup)?.Links;

            Assert.Single(linkReferenceDefinitions);
            Assert.Same(dummyLinkReferenceDefinition, linkReferenceDefinitions.Values.First()); // Doesn't get replaced
        }
Example #2
0
        public void DocumentOnProcessInlinesBegin_CreatesAndAddsALinkReferenceDefinitionForEachReferenceLinkableFlexiFigureBlock()
        {
            // Arrange
            const string     dummyLinkLabelContent = "dummyLinkLabelContent";
            const string     dummyID               = "dummyID";
            const string     dummyName             = "dummyName";
            FlexiFigureBlock dummyFlexiFigureBlock = CreateFlexiFigureBlock(name: dummyName, linkLabelContent: dummyLinkLabelContent, id: dummyID);
            InlineProcessor  dummyInlineProcessor  = MarkdigTypesFactory.CreateInlineProcessor();

            dummyInlineProcessor.Document.SetData(FlexiFigureBlockFactory.REFERENCE_LINKABLE_FLEXI_FIGURE_BLOCKS_KEY, new List <FlexiFigureBlock> {
                dummyFlexiFigureBlock
            });
            FlexiFigureBlockFactory testSubject = CreateFlexiFigureBlockFactory();

            // Act
            testSubject.DocumentOnProcessInlinesBegin(dummyInlineProcessor, null);

            // Assert
            Dictionary <string, LinkReferenceDefinition> linkReferenceDefinitions = (dummyInlineProcessor.Document.GetData(typeof(LinkReferenceDefinitionGroup)) as LinkReferenceDefinitionGroup)?.Links;

            Assert.Single(linkReferenceDefinitions);
            LinkReferenceDefinition resultLinkReferenceDefinition = linkReferenceDefinitions.Values.First();

            Assert.Equal(dummyLinkLabelContent, resultLinkReferenceDefinition.Label);
            Assert.Equal($"#{dummyID}", resultLinkReferenceDefinition.Url);
            Assert.Equal(dummyName, resultLinkReferenceDefinition.Title);
        }