Пример #1
0
 private static FlexiTabBlock CreateFlexiTabBlock(ReadOnlyDictionary <string, string> attributes = default,
                                                  BlockParser blockParser       = default,
                                                  PlainLeafBlock tabPart        = default,
                                                  PlainContainerBlock panelPart = default)
 {
     return(new FlexiTabBlock(attributes, blockParser)
     {
         tabPart ?? new PlainLeafBlock(blockParser),
         panelPart ?? new PlainContainerBlock(blockParser),
     });
 }
Пример #2
0
 private static FlexiCardBlock CreateFlexiCardBlock(string url            = default,
                                                    string backgroundIcon = default,
                                                    ReadOnlyDictionary <string, string> attributes = default,
                                                    BlockParser blockParser         = default,
                                                    PlainLeafBlock titlePart        = default,
                                                    PlainContainerBlock contentPart = default,
                                                    PlainLeafBlock footnotePart     = default)
 {
     return(new FlexiCardBlock(url, backgroundIcon, attributes, blockParser)
     {
         titlePart ?? new PlainLeafBlock(blockParser),
         contentPart ?? new PlainContainerBlock(blockParser),
         footnotePart ?? new PlainLeafBlock(blockParser),
     });
 }
 private static FlexiFigureBlock CreateFlexiFigureBlock(string blockName     = default,
                                                        string name          = default,
                                                        bool renderName      = default,
                                                        string autoLinkLabel = default,
                                                        string id            = default,
                                                        ReadOnlyDictionary <string, string> attributes = default,
                                                        BlockParser blockParser         = default,
                                                        PlainContainerBlock contentPart = default,
                                                        PlainLeafBlock captionPart      = default)
 {
     return(new FlexiFigureBlock(blockName, name, renderName, autoLinkLabel, id, attributes, blockParser)
     {
         contentPart ?? new PlainContainerBlock(null), captionPart ?? new PlainLeafBlock(null)
     });
 }
Пример #4
0
        public void WriteBlock_OnlyWritesChildrenIfEnableHtmlForBlockIsFalse()
        {
            // Arrange
            // Dummy title part
            const string dummyTitle = "dummyTitle";
            var          dummyTitleContainerInline = new ContainerInline();

            dummyTitleContainerInline.AppendChild(new LiteralInline(dummyTitle));
            var dummyTitlePartBlock = new PlainLeafBlock(null);

            dummyTitlePartBlock.Inline = dummyTitleContainerInline;
            // Dummy content part
            const string dummyContent = "dummyContent";
            var          dummyContentContainerInline = new ContainerInline();

            dummyContentContainerInline.AppendChild(new LiteralInline(dummyContent));
            var dummyContentParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyContentContainerInline
            };
            var dummyContentPartBlock = new PlainContainerBlock(null);

            dummyContentPartBlock.Add(dummyContentParagraphBlock);
            // Dummy footnote part
            const string dummyFootnote = "dummyFootnote";
            var          dummyFootnoteContainerInline = new ContainerInline();

            dummyFootnoteContainerInline.AppendChild(new LiteralInline(dummyFootnote));
            var dummyFootnotePartBlock = new PlainLeafBlock(null);

            dummyFootnotePartBlock.Inline = dummyFootnoteContainerInline;
            FlexiCardsBlock dummyFlexiCardsBlock = CreateFlexiCardsBlock(children: new List <FlexiCardBlock> {
                CreateFlexiCardBlock(titlePart: dummyTitlePartBlock, contentPart: dummyContentPartBlock, footnotePart: dummyFootnotePartBlock)
            });
            var dummyStringWriter = new StringWriter();
            var dummyHtmlRenderer = new HtmlRenderer(dummyStringWriter)
            {
                EnableHtmlForBlock = false
            };
            ExposedFlexiCardsBlockRenderer testSubject = CreateExposedFlexiCardsBlockRenderer();

            // Act
            testSubject.ExposedWriteBlock(dummyHtmlRenderer, dummyFlexiCardsBlock);
            string result = dummyStringWriter.ToString();

            // Assert
            Assert.Equal($"{dummyTitle}\n{dummyContent}\n{dummyFootnote}\n", result, ignoreLineEndingDifferences: true);
        }
Пример #5
0
        private static FlexiQuoteBlock CreateFlexiQuoteBlock(string blockName = default,
                                                             string icon      = default,
                                                             int citeLink     = default,
                                                             ReadOnlyDictionary <string, string> attributes = default,
                                                             BlockParser blockParser       = default,
                                                             string citeUrl                = default,
                                                             PlainContainerBlock quotePart = default,
                                                             PlainLeafBlock citationPart   = default)
        {
            var result = new FlexiQuoteBlock(blockName, icon, citeLink, attributes, blockParser)
            {
                quotePart ?? new PlainContainerBlock(null), citationPart ?? new PlainLeafBlock(null)
            };

            result.CiteUrl = citeUrl;

            return(result);
        }
Пример #6
0
        public void WriteBlock_OnlyWritesChildrenIfEnableHtmlForBlockIsFalse()
        {
            // Arrange
            // Dummy tab part
            const string dummyTab = "dummyTab";
            var          dummyTabContainerInline = new ContainerInline();

            dummyTabContainerInline.AppendChild(new LiteralInline(dummyTab));
            var dummyTabPartBlock = new PlainLeafBlock(null);

            dummyTabPartBlock.Inline = dummyTabContainerInline;
            // Dummy panel part
            const string dummyPanel = "dummyPanel";
            var          dummyPanelContainerInline = new ContainerInline();

            dummyPanelContainerInline.AppendChild(new LiteralInline(dummyPanel));
            var dummyPanelParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyPanelContainerInline
            };
            var dummyPanelPartBlock = new PlainContainerBlock(null);

            dummyPanelPartBlock.Add(dummyPanelParagraphBlock);
            FlexiTabsBlock dummyFlexiTabsBlock = CreateFlexiTabsBlock(children: new List <FlexiTabBlock> {
                CreateFlexiTabBlock(tabPart: dummyTabPartBlock, panelPart: dummyPanelPartBlock)
            });
            var dummyStringWriter = new StringWriter();
            var dummyHtmlRenderer = new HtmlRenderer(dummyStringWriter)
            {
                EnableHtmlForBlock = false
            };
            ExposedFlexiTabsBlockRenderer testSubject = CreateExposedFlexiTabsBlockRenderer();

            // Act
            testSubject.ExposedWriteBlock(dummyHtmlRenderer, dummyFlexiTabsBlock);
            string result = dummyStringWriter.ToString();

            // Assert
            Assert.Equal($"{dummyTab}\n{dummyPanel}\n", result, ignoreLineEndingDifferences: true);
        }
Пример #7
0
        public void WriteBlock_OnlyWritesChildrenIfEnableHtmlForBlockIsFalse()
        {
            // Arrange
            const string dummyQuote = "dummyQuote";
            var          dummyQuoteContainerInline = new ContainerInline();

            dummyQuoteContainerInline.AppendChild(new LiteralInline(dummyQuote));
            var dummyQuoteParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyQuoteContainerInline
            };
            var dummyQuotePartBlock = new PlainContainerBlock(null);

            dummyQuotePartBlock.Add(dummyQuoteParagraphBlock);
            const string dummyCitation = "dummyCitation";
            var          dummyCitationContainerInline = new ContainerInline();

            dummyCitationContainerInline.AppendChild(new LiteralInline(dummyCitation));
            var dummyCitationPartBlock = new PlainLeafBlock(null);

            dummyCitationPartBlock.Inline = dummyCitationContainerInline;
            FlexiQuoteBlock dummyFlexiQuoteBlock = CreateFlexiQuoteBlock(quotePart: dummyQuotePartBlock, citationPart: dummyCitationPartBlock);
            var             dummyStringWriter    = new StringWriter();
            var             dummyHtmlRenderer    = new HtmlRenderer(dummyStringWriter)
            {
                EnableHtmlForBlock = false
            };
            ExposedFlexiQuoteBlockRenderer testSubject = CreateExposedFlexiQuoteBlockRenderer();

            // Act
            testSubject.ExposedWriteBlock(dummyHtmlRenderer, dummyFlexiQuoteBlock);
            string result = dummyStringWriter.ToString();

            // Assert
            Assert.Equal($"{dummyQuote}\n{dummyCitation}\n", result, ignoreLineEndingDifferences: true);
        }
Пример #8
0
        public static IEnumerable <object[]> WriteBlock_WritesBlock_Data()
        {
            const string             dummyBlockName       = "dummyBlockName";
            const FlexiCardBlockSize dummyCardSize        = FlexiCardBlockSize.Medium;
            const string             dummyAttributeKey1   = "dummyAttributeKey1";
            const string             dummyAttributeValue1 = "dummyAttributeValue1";
            const string             dummyAttributeKey2   = "dummyAttributeKey2";
            const string             dummyAttributeValue2 = "dummyAttributeValue2";
            const string             dummyClass           = "dummyClass";

            // Dummy title part
            const string dummyTitle = "dummyTitle";
            var          dummyTitleContainerInline = new ContainerInline();

            dummyTitleContainerInline.AppendChild(new LiteralInline(dummyTitle));
            var dummyTitlePartBlock = new PlainLeafBlock(null);

            dummyTitlePartBlock.Inline = dummyTitleContainerInline;

            // Dummy content part
            const string dummyContent = "dummyContent";
            var          dummyContentContainerInline = new ContainerInline();

            dummyContentContainerInline.AppendChild(new LiteralInline(dummyContent));
            var dummyContentParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyContentContainerInline
            };
            var dummyContentPartBlock = new PlainContainerBlock(null);

            dummyContentPartBlock.Add(dummyContentParagraphBlock);

            // Dummy footnote part
            const string dummyFootnote = "dummyFootnote";
            var          dummyFootnoteContainerInline = new ContainerInline();

            dummyFootnoteContainerInline.AppendChild(new LiteralInline(dummyFootnote));
            var dummyFootnotePartBlock = new PlainLeafBlock(null);

            dummyFootnotePartBlock.Inline = dummyFootnoteContainerInline;

            return(new object[][]
            {
                // BlockName is assigned as a class of the root element and all default classes are prepended with it
                new object[] {
                    CreateFlexiCardsBlock(dummyBlockName),
                    $@"<div class=""{dummyBlockName} {dummyBlockName}_size_small"">
</div>
"
                },
                // CardSize is rendered in a modifier class of the root element
                new object[] {
                    CreateFlexiCardsBlock(cardSize: dummyCardSize),
                    $@"<div class="" _size_{dummyCardSize.ToString().ToLower()}"">
</div>
"
                },
                // If attributes are specified, they're written
                new object[] {
                    CreateFlexiCardsBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { dummyAttributeKey1, dummyAttributeValue1 }, { dummyAttributeKey2, dummyAttributeValue2 }
                    })),
                    $@"<div class="" _size_small"" {dummyAttributeKey1}=""{dummyAttributeValue1}"" {dummyAttributeKey2}=""{dummyAttributeValue2}"">
</div>
"
                },
                // If classes are specified, they're appended to default classes
                new object[] {
                    CreateFlexiCardsBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "class", dummyClass }
                    })),
                    $@"<div class="" _size_small {dummyClass}"">
</div>
"
                },
                // Child FlexiCardBlocks are rendered
                new object[] {
                    CreateFlexiCardsBlock(children: new List <FlexiCardBlock> {
                        CreateFlexiCardBlock(titlePart: dummyTitlePartBlock, contentPart: dummyContentPartBlock, footnotePart: dummyFootnotePartBlock)
                    }),
                    $@"<div class="" _size_small"">
<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title"">{dummyTitle}</p>
<div class=""__card-content"">
<p>{dummyContent}</p>
</div>
<p class=""__card-footnote"">{dummyFootnote}</p>
</div>
</div>
"
                }
            });
        }
Пример #9
0
        public static IEnumerable <object[]> WriteCard_WritesCard_Data()
        {
            const string dummyUrl                     = "dummyUrl\"&";
            const string dummyUrlEncoded              = "dummyUrl%22&amp;"; // Encodes URL for use as HTML attribute value
            const string dummyBlockName               = "dummyBlockName";
            const string dummyAttributeKey1           = "dummyAttributeKey1";
            const string dummyAttributeValue1         = "dummyAttributeValue1";
            const string dummyAttributeKey2           = "dummyAttributeKey2";
            const string dummyAttributeValue2         = "dummyAttributeValue2";
            const string dummyClass                   = "dummyClass";
            const string dummyBackgroundIcon          = "<dummyBackgroundIcon></dummyBackgroundIcon>";
            const string dummyBackgroundIconWithClass = "<dummyBackgroundIcon class=\"__card-background-icon\"></dummyBackgroundIcon>";

            // Dummy title part
            const string dummyTitle = "dummyTitle";
            var          dummyTitleContainerInline = new ContainerInline();

            dummyTitleContainerInline.AppendChild(new LiteralInline(dummyTitle));
            var dummyTitlePartBlock = new PlainLeafBlock(null);

            dummyTitlePartBlock.Inline = dummyTitleContainerInline;

            // Dummy content part
            const string dummyContent = "dummyContent";
            var          dummyContentContainerInline = new ContainerInline();

            dummyContentContainerInline.AppendChild(new LiteralInline(dummyContent));
            var dummyContentParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyContentContainerInline
            };
            var dummyContentPartBlock = new PlainContainerBlock(null);

            dummyContentPartBlock.Add(dummyContentParagraphBlock);

            // Dummy footnote part
            const string dummyFootnote = "dummyFootnote";
            var          dummyFootnoteContainerInline = new ContainerInline();

            dummyFootnoteContainerInline.AppendChild(new LiteralInline(dummyFootnote));
            var dummyFootnotePartBlock = new PlainLeafBlock(null);

            dummyFootnotePartBlock.Inline = dummyFootnoteContainerInline;

            return(new object[][]
            {
                // Root element has tag name "a", has a href attribute and has an is_link modifier class if URL is specified
                new object[] {
                    CreateFlexiCardBlock(url: dummyUrl),
                    null,
                    $@"<a class=""__card __card_is-link __card_no-background-icon"" href=""{dummyUrlEncoded}"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</a>
"
                },
                // Root element tag name is div if URL is null, whitespace or an empty string (null case already verified in other tests)
                new object[] {
                    CreateFlexiCardBlock(url: " "),
                    null,
                    @"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                new object[] {
                    CreateFlexiCardBlock(url: string.Empty),
                    null,
                    @"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // BlockName prepended to all default classes
                new object[] {
                    CreateFlexiCardBlock(),
                    dummyBlockName,
                    $@"<div class=""{dummyBlockName}__card {dummyBlockName}__card_not-link {dummyBlockName}__card_no-background-icon"">
<p class=""{dummyBlockName}__card-title""></p>
<div class=""{dummyBlockName}__card-content"">
</div>
<p class=""{dummyBlockName}__card-footnote""></p>
</div>
"
                },
                // If background icon is valid HTML, it is rendered with a default class and a _has-background-icon class is rendered
                new object[] {
                    CreateFlexiCardBlock(backgroundIcon: dummyBackgroundIcon),
                    null,
                    $@"<div class=""__card __card_not-link __card_has-background-icon"">
{dummyBackgroundIconWithClass}
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // If background icon is null, whitespace or an empty string, no icon is rendered and a _no-background-icon class is rendered (null case already verified in other tests)
                new object[] {
                    CreateFlexiCardBlock(backgroundIcon: " "),
                    null,
                    @"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                new object[] {
                    CreateFlexiCardBlock(backgroundIcon: string.Empty),
                    null,
                    @"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // If attributes are specified, they're written
                new object[] {
                    CreateFlexiCardBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { dummyAttributeKey1, dummyAttributeValue1 }, { dummyAttributeKey2, dummyAttributeValue2 }
                    })),
                    null,
                    $@"<div class=""__card __card_not-link __card_no-background-icon"" {dummyAttributeKey1}=""{dummyAttributeValue1}"" {dummyAttributeKey2}=""{dummyAttributeValue2}"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // If classes are specified, they're appended to default classes
                new object[] {
                    CreateFlexiCardBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "class", dummyClass }
                    })),
                    null,
                    $@"<div class=""__card __card_not-link __card_no-background-icon {dummyClass}"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // Title part is rendered
                new object[] {
                    CreateFlexiCardBlock(titlePart: dummyTitlePartBlock),
                    null,
                    $@"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title"">{dummyTitle}</p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // Content part is rendered
                new object[] {
                    CreateFlexiCardBlock(contentPart: dummyContentPartBlock),
                    null,
                    $@"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title""></p>
<div class=""__card-content"">
<p>{dummyContent}</p>
</div>
<p class=""__card-footnote""></p>
</div>
"
                },
                // Footnote part is rendered
                new object[] {
                    CreateFlexiCardBlock(footnotePart: dummyFootnotePartBlock),
                    null,
                    $@"<div class=""__card __card_not-link __card_no-background-icon"">
<p class=""__card-title""></p>
<div class=""__card-content"">
</div>
<p class=""__card-footnote"">{dummyFootnote}</p>
</div>
"
                }
            });
        }
Пример #10
0
        public static IEnumerable <object[]> WriteBlock_WritesBlock_Data()
        {
            const string dummyBlockName       = "dummyBlockName";
            const string dummyCiteUrl         = "dummyCiteUrl";
            const string dummyAttributeKey1   = "dummyAttributeKey1";
            const string dummyAttributeValue1 = "dummyAttributeValue1";
            const string dummyAttributeKey2   = "dummyAttributeKey2";
            const string dummyAttributeValue2 = "dummyAttributeValue2";
            const string dummyClass           = "dummyClass";
            const string dummyIcon            = "<dummyIcon></dummyIcon>";
            const string dummyIconWithClass   = "<dummyIcon class=\"__icon\"></dummyIcon>";

            // Dummy quote part
            const string dummyQuote = "dummyQuote";
            var          dummyQuoteContainerInline = new ContainerInline();

            dummyQuoteContainerInline.AppendChild(new LiteralInline(dummyQuote));
            var dummyQuoteParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyQuoteContainerInline
            };
            var dummyQuotePartBlock = new PlainContainerBlock(null);

            dummyQuotePartBlock.Add(dummyQuoteParagraphBlock);

            // Dummy citation part
            const string dummyCitation = "dummyCitation";
            var          dummyCitationContainerInline = new ContainerInline();

            dummyCitationContainerInline.AppendChild(new LiteralInline(dummyCitation));
            var dummyCitationPartBlock = new PlainLeafBlock(null);

            dummyCitationPartBlock.Inline = dummyCitationContainerInline;

            return(new object[][]
            {
                // BlockName is assigned as a class of the root element and all default classes are prepended with it
                new object[] {
                    CreateFlexiQuoteBlock(dummyBlockName),
                    $@"<div class=""{dummyBlockName} {dummyBlockName}_no-icon"">
<div class=""{dummyBlockName}__content"">
<blockquote class=""{dummyBlockName}__blockquote"">
</blockquote>
<p class=""{dummyBlockName}__citation"">— </p>
</div>
</div>
"
                },
                // If icon is valid HTML, it is rendered with a default class and a _has-icon class is rendered
                new object[] {
                    CreateFlexiQuoteBlock(icon: dummyIcon),
                    $@"<div class="" _has-icon"">
{dummyIconWithClass}
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // If icon is null, whitespace or an empty string, no icon is rendered and a _no-icon class is rendered (null case already verified in other tests)
                new object[] {
                    CreateFlexiQuoteBlock(icon: " "),
                    @"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                new object[] {
                    CreateFlexiQuoteBlock(icon: string.Empty),
                    @"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // If attributes are specified, they're written
                new object[] {
                    CreateFlexiQuoteBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { dummyAttributeKey1, dummyAttributeValue1 }, { dummyAttributeKey2, dummyAttributeValue2 }
                    })),
                    $@"<div class="" _no-icon"" {dummyAttributeKey1}=""{dummyAttributeValue1}"" {dummyAttributeKey2}=""{dummyAttributeValue2}"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // If classes are specified, they're appended to default classes
                new object[] {
                    CreateFlexiQuoteBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "class", dummyClass }
                    })),
                    $@"<div class="" _no-icon {dummyClass}"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // If CiteUrl is specified, it is assigned to the blockquote element's cite attribute
                new object[] {
                    CreateFlexiQuoteBlock(citeUrl: dummyCiteUrl),
                    $@"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"" cite=""{dummyCiteUrl}"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // If CiteUrl is null, whitespace or an empty string, no cite attribute is rendered for the blockquote element (null case already verified in other tests)
                new object[] {
                    CreateFlexiQuoteBlock(citeUrl: " "),
                    @"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                new object[] {
                    CreateFlexiQuoteBlock(citeUrl: string.Empty),
                    @"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // Quote part is rendered
                new object[] {
                    CreateFlexiQuoteBlock(quotePart: dummyQuotePartBlock),
                    $@"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"">
<p>{dummyQuote}</p>
</blockquote>
<p class=""__citation"">— </p>
</div>
</div>
"
                },
                // Citation part is rendered
                new object[] {
                    CreateFlexiQuoteBlock(citationPart: dummyCitationPartBlock),
                    $@"<div class="" _no-icon"">
<div class=""__content"">
<blockquote class=""__blockquote"">
</blockquote>
<p class=""__citation"">— {dummyCitation}</p>
</div>
</div>
"
                }
            });
        }
        public static IEnumerable <object[]> WriteBlock_WritesBlock_Data()
        {
            const string dummyBlockName       = "dummyBlockName";
            const string dummyName            = "dummyName";
            const string dummyAttributeKey1   = "dummyAttributeKey1";
            const string dummyAttributeValue1 = "dummyAttributeValue1";
            const string dummyAttributeKey2   = "dummyAttributeKey2";
            const string dummyAttributeValue2 = "dummyAttributeValue2";
            const string dummyClass           = "dummyClass";
            const string dummyID = "dummyID";

            // Dummy content part
            const string dummyContent = "dummyContent";
            var          dummyContentContainerInline = new ContainerInline();

            dummyContentContainerInline.AppendChild(new LiteralInline(dummyContent));
            var dummyContentParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyContentContainerInline
            };
            var dummyContentPartBlock = new PlainContainerBlock(null);

            dummyContentPartBlock.Add(dummyContentParagraphBlock);

            // Dummy caption part
            const string dummyCaption = "dummyCaption";
            var          dummyCaptionContainerInline = new ContainerInline();

            dummyCaptionContainerInline.AppendChild(new LiteralInline(dummyCaption));
            var dummyCaptionPartBlock = new PlainLeafBlock(null);

            dummyCaptionPartBlock.Inline = dummyCaptionContainerInline;

            return(new object[][]
            {
                // BlockName is assigned as a class of the root element and all default classes are prepended with it
                new object[] {
                    CreateFlexiFigureBlock(dummyBlockName),
                    $@"<figure class=""{dummyBlockName} {dummyBlockName}_no-name"">
<div class=""{dummyBlockName}__content"">
</div>
<figcaption class=""{dummyBlockName}__caption""></figcaption>
</figure>
"
                },
                // If attributes are specified, they're written
                new object[] {
                    CreateFlexiFigureBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { dummyAttributeKey1, dummyAttributeValue1 }, { dummyAttributeKey2, dummyAttributeValue2 }
                    })),
                    $@"<figure class="" _no-name"" {dummyAttributeKey1}=""{dummyAttributeValue1}"" {dummyAttributeKey2}=""{dummyAttributeValue2}"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // If classes are specified, they're appended to default classes
                new object[] {
                    CreateFlexiFigureBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "class", dummyClass }
                    })),
                    $@"<figure class="" _no-name {dummyClass}"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // If ID (FlexiFigureBlock property) is specified, it is written
                new object[] {
                    CreateFlexiFigureBlock(id: dummyID),
                    $@"<figure class="" _no-name"" id=""{dummyID}"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // ID in attributes is never written
                new object[] {
                    CreateFlexiFigureBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "id", dummyID }
                    })),
                    @"<figure class="" _no-name"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // Content part is rendered
                new object[] {
                    CreateFlexiFigureBlock(contentPart: dummyContentPartBlock),
                    $@"<figure class="" _no-name"">
<div class=""__content"">
<p>{dummyContent}</p>
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // If RenderName is true and Name is not null, whitespace or an empty string, Name is rendered in caption
                new object[] {
                    CreateFlexiFigureBlock(name: dummyName, renderName: true),
                    $@"<figure class="" _has-name"">
<div class=""__content"">
</div>
<figcaption class=""__caption""><span class=""__name"">{dummyName}. </span></figcaption>
</figure>
"
                },
                // If RenderName is false, Name isn't rendered even if Name is not null, whitespace or an empty string
                new object[] {
                    CreateFlexiFigureBlock(name: dummyName, renderName: false),
                    @"<figure class="" _no-name"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // If Name is null, whitespace or an empty string, Name isn't is rendered even if RenderName is true (null case already verified in other tests)
                new object[] {
                    CreateFlexiFigureBlock(name: " ", renderName: true),
                    @"<figure class="" _no-name"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                new object[] {
                    CreateFlexiFigureBlock(name: string.Empty, renderName: true),
                    @"<figure class="" _no-name"">
<div class=""__content"">
</div>
<figcaption class=""__caption""></figcaption>
</figure>
"
                },
                // Caption part is rendered
                new object[] {
                    CreateFlexiFigureBlock(captionPart: dummyCaptionPartBlock),
                    $@"<figure class="" _no-name"">
<div class=""__content"">
</div>
<figcaption class=""__caption"">{dummyCaption}</figcaption>
</figure>
"
                }
            });
        }
Пример #12
0
        public static IEnumerable <object[]> WriteBlock_WritesBlock_Data()
        {
            const string dummyBlockName       = "dummyBlockName";
            const string dummyAttributeKey1   = "dummyAttributeKey1";
            const string dummyAttributeValue1 = "dummyAttributeValue1";
            const string dummyAttributeKey2   = "dummyAttributeKey2";
            const string dummyAttributeValue2 = "dummyAttributeValue2";
            const string dummyClass           = "dummyClass";

            // Dummy tab part
            const string dummyTab = "dummyTab";
            var          dummyTabContainerInline = new ContainerInline();

            dummyTabContainerInline.AppendChild(new LiteralInline(dummyTab));
            var dummyTabPartBlock = new PlainLeafBlock(null);

            dummyTabPartBlock.Inline = dummyTabContainerInline;

            // Dummy panel part
            const string dummyPanel = "dummyPanel";
            var          dummyPanelContainerInline = new ContainerInline();

            dummyPanelContainerInline.AppendChild(new LiteralInline(dummyPanel));
            var dummyPanelParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyPanelContainerInline
            };
            var dummyPanelPartBlock = new PlainContainerBlock(null);

            dummyPanelPartBlock.Add(dummyPanelParagraphBlock);

            return(new object[][]
            {
                // BlockName is assigned as a class of the root element and all default classes are prepended with it
                new object[] {
                    CreateFlexiTabsBlock(dummyBlockName),
                    $@"<div class=""{dummyBlockName}"">
<div class=""{dummyBlockName}__scrollable-indicators scrollable-indicators scrollable-indicators_axis_horizontal"">
<div class=""{dummyBlockName}__tab-list scrollable-indicators__scrollable"" role=""tablist"">
</div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_start""></div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_end""></div>
</div>
</div>
"
                },
                // If attributes are specified, they're written
                new object[] {
                    CreateFlexiTabsBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { dummyAttributeKey1, dummyAttributeValue1 }, { dummyAttributeKey2, dummyAttributeValue2 }
                    })),
                    $@"<div class="""" {dummyAttributeKey1}=""{dummyAttributeValue1}"" {dummyAttributeKey2}=""{dummyAttributeValue2}"">
<div class=""__scrollable-indicators scrollable-indicators scrollable-indicators_axis_horizontal"">
<div class=""__tab-list scrollable-indicators__scrollable"" role=""tablist"">
</div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_start""></div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_end""></div>
</div>
</div>
"
                },
                // If classes are specified, they're appended to default classes
                new object[] {
                    CreateFlexiTabsBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "class", dummyClass }
                    })),
                    $@"<div class="" {dummyClass}"">
<div class=""__scrollable-indicators scrollable-indicators scrollable-indicators_axis_horizontal"">
<div class=""__tab-list scrollable-indicators__scrollable"" role=""tablist"">
</div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_start""></div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_end""></div>
</div>
</div>
"
                },
                // Child FlexiTabBlocks are rendered
                new object[] {
                    CreateFlexiTabsBlock(children: new List <FlexiTabBlock> {
                        CreateFlexiTabBlock(tabPart: dummyTabPartBlock, panelPart: dummyPanelPartBlock)
                    }),
                    $@"<div class="""">
<div class=""__scrollable-indicators scrollable-indicators scrollable-indicators_axis_horizontal"">
<div class=""__tab-list scrollable-indicators__scrollable"" role=""tablist"">
<button class=""__tab __tab_selected"" role=""tab"" aria-selected=""true"">{dummyTab}</button>
</div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_start""></div>
<div class=""scrollable-indicators__indicator scrollable-indicators__indicator_end""></div>
</div>
<div class=""__tab-panel"" tabindex=""0"" role=""tabpanel"" aria-label=""{dummyTab}"">
<p>{dummyPanel}</p>
</div>
</div>
"
                }
            });
        }
Пример #13
0
        public static IEnumerable <object[]> WritePanel_WritesPanel_Data()
        {
            const string dummyBlockName       = "dummyBlockName";
            const string dummyAttributeKey1   = "dummyAttributeKey1";
            const string dummyAttributeValue1 = "dummyAttributeValue1";
            const string dummyAttributeKey2   = "dummyAttributeKey2";
            const string dummyAttributeValue2 = "dummyAttributeValue2";
            const string dummyClass           = "dummyClass";

            // Dummy tab part
            const string dummyTab = "dummyTab";
            var          dummyTabContainerInline = new ContainerInline();

            dummyTabContainerInline.AppendChild(new LiteralInline(dummyTab));
            var dummyTabPartBlock = new PlainLeafBlock(null);

            dummyTabPartBlock.Inline = dummyTabContainerInline;

            // Dummy panel part
            const string dummyPanel = "dummyPanel";
            var          dummyPanelContainerInline = new ContainerInline();

            dummyPanelContainerInline.AppendChild(new LiteralInline(dummyPanel));
            var dummyPanelParagraphBlock = new ParagraphBlock()
            {
                Inline = dummyPanelContainerInline
            };
            var dummyPanelPartBlock = new PlainContainerBlock(null);

            dummyPanelPartBlock.Add(dummyPanelParagraphBlock);

            return(new object[][]
            {
                // BlockName prepended to all default classes
                new object[] {
                    CreateFlexiTabBlock(),
                    dummyBlockName,
                    0,
                    $@"<div class=""{dummyBlockName}__tab-panel"" tabindex=""0"" role=""tabpanel"" aria-label="""">
</div>
"
                },
                // Root element has hidden modifier class if index is larger than 0 (index 0 case covered by other tests)
                new object[] {
                    CreateFlexiTabBlock(),
                    null,
                    1,
                    @"<div class=""__tab-panel __tab-panel_hidden"" tabindex=""0"" role=""tabpanel"" aria-label="""">
</div>
"
                },
                // If attributes are specified, they're written
                new object[] {
                    CreateFlexiTabBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { dummyAttributeKey1, dummyAttributeValue1 }, { dummyAttributeKey2, dummyAttributeValue2 }
                    })),
                    null,
                    0,
                    $@"<div class=""__tab-panel"" {dummyAttributeKey1}=""{dummyAttributeValue1}"" {dummyAttributeKey2}=""{dummyAttributeValue2}"" tabindex=""0"" role=""tabpanel"" aria-label="""">
</div>
"
                },
                // If classes are specified, they're appended to default classes
                new object[] {
                    CreateFlexiTabBlock(attributes: new ReadOnlyDictionary <string, string>(new Dictionary <string, string> {
                        { "class", dummyClass }
                    })),
                    null,
                    0,
                    $@"<div class=""__tab-panel {dummyClass}"" tabindex=""0"" role=""tabpanel"" aria-label="""">
</div>
"
                },
                // Tab part is rendered as aria-label value
                new object[] {
                    CreateFlexiTabBlock(tabPart: dummyTabPartBlock),
                    null,
                    0,
                    $@"<div class=""__tab-panel"" tabindex=""0"" role=""tabpanel"" aria-label=""{dummyTab}"">
</div>
"
                },
                // Panel part is rendered
                new object[] {
                    CreateFlexiTabBlock(panelPart: dummyPanelPartBlock),
                    null,
                    0,
                    $@"<div class=""__tab-panel"" tabindex=""0"" role=""tabpanel"" aria-label="""">
<p>{dummyPanel}</p>
</div>
"
                }
            });
        }