Beispiel #1
0
        public static void AssertText(this Document document, TestContext testContext, string text, bool hasSaved = false, bool convertFieldCodes = false, bool asMarkdown = false)
        {
            const string noLicenseMessage = @"Evaluation Only. Created with Aspose.Words. Copyright 2003-2011 Aspose Pty Ltd.";

            string expectedText;

            if (asMarkdown)
            {
                var writer = new DocumentTemplateWriter();

                writer.InsertMarkdown(text);

                expectedText = convertFieldCodes
                    ? DocumentConverter.ConvertCodeToDisplay(writer.Document.GetText().Replace("\r\f", "\r\n").Replace("\f", "\r\n"))
                    : string.Join("\r\n", writer.Document.ToString(SaveFormat.Text).Split(new[] { "\r\n" }, StringSplitOptions.None).Select(l => l.TrimStart()));

                expectedText = expectedText.Replace("\r\n", "¶\r\n");
            }
            else
            {
                // Trim leading whitespace from lines and add the paragraph symbol at the end of each line.
                var expectedLines = text.Split(new[] {"\r\n"}, StringSplitOptions.None);
                if (hasSaved && !DocumentTestsBase.HasLicense)
                    expectedLines = new[] {noLicenseMessage}.Concat(expectedLines).ToArray();
                expectedText = string.Join("¶\r\n", expectedLines.Select(l => l.TrimStart()));
            }

            var actualText = convertFieldCodes
                ? DocumentConverter.ConvertCodeToDisplay(document.GetText().Replace("\r\f", "\r\n").Replace("\f", "\r\n"))
                : string.Join("\r\n", document.ToString(SaveFormat.Text).Split(new[] {"\r\n"}, StringSplitOptions.None).Select(l => l.TrimStart()));

            // Add the paragraph symbol at the end of each line.
            actualText = actualText.Replace("\r\n", "¶\r\n");

            try
            {
                AssertLines.Match(expectedText, actualText, "¶\r\n");
            }
            catch
            {
                document.Save("C:\\Temp\\" + testContext.TestName + ".docx");

                throw;
            }
        }
Beispiel #2
0
        public void MergeDocText_ListInSingleRowTable_EmptyRowPreserved()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Items                                                                |
                | -------------------------------------------------------------------- |
                | {{ each Items }}{{ Name }}, {{ InStock }}, {{ Price }}{{ end each }} |

                ");

            var data = new
            {
                Items = new object[0],
            };

            writer.Document.Merge(data, keepEmptyRows: true);

            writer.Document.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                      </Paragraph>
                      <Table preferredwidth='Auto'>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Items</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                          </Cell>
                        </Row>
                      </Table>
                      <Paragraph>
                      </Paragraph>
                      <Paragraph>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");
        }
Beispiel #3
0
        public void MergeDocText_ListInSingleCellTableSameParagraph_RowIsRepeatedForEachItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                                     |
                | ---------------------------------------- |
                | {{ each Items }}{{ Name }}{{ end each }} |

                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk" },
                        new {Name = "Eggs" },
                        new {Name = "Artisan Bread" }
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"
                Item
                Milk
                Eggs
                Artisan Bread

                ");

            Assert.AreEqual(4, writer.Document.SelectNodes("//Row").Count, "The row should be repeated for each item.");
            Assert.AreEqual(4, writer.Document.SelectNodes("//Cell").Count, "The cell should be repeated in each row.");
        }
Beispiel #4
0
        public void MergeDocText_ListInSingleCellTableSameParagraphTrailingContent_RowIsRepeatedForEachItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                                                  |
                | ----------------------------------------------------- |
                | {{ each Items }}{{ Name }},{{ end each }} ... FOOTER |

                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk" },
                        new {Name = "Eggs" },
                        new {Name = "Artisan Bread" }
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"
                Item
                Milk,Eggs,Artisan Bread, ... FOOTER

                ");

            Assert.AreEqual(2, writer.Document.SelectNodes("//Row").Count, "The row should not be repeated.");
            Assert.AreEqual(2, writer.Document.SelectNodes("//Cell").Count, "The cell should not be repeated.");
        }
Beispiel #5
0
        public void MergeDocText_ListInSingleCellTableDifferentParagraphsLeadingContent_RowIsRepeatedForEachItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                                                  |
                | ----------------------------------------------------- |
                | HEADER:\n{{ each Items }}\n{{ Name }}\n{{ end each }} |

                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk" },
                        new {Name = "Eggs" },
                        new {Name = "Artisan Bread" }
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"
                Item
                HEADER:
                Milk
                Eggs
                Artisan Bread

                ");

            Assert.AreEqual(2, writer.Document.SelectNodes("//Row").Count, "The row should not be repeated.");
            Assert.AreEqual(2, writer.Document.SelectNodes("//Cell").Count, "The cell should not be repeated.");
        }
Beispiel #6
0
        public void MergeDocText_ListWithCheckboxes()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                                                           |
                | -------------------------------------------------------------- |
                | {{ each Items }}{{ checkbox InStock }} {{ Name }}{{ end each }} |

                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk", InStock = true },
                        new {Name = "Eggs", InStock = true },
                        new {Name = "Artisan Bread", InStock = false }
                    },
            };

            var generatorFactory = new KeywordGeneratorFactory<IGenerator<Document, Node, Type, object, string>>();

            generatorFactory.Generators.Add("checkbox", new CheckBoxSymbolGenerator<Type, object, string>());

            writer.Document.Merge(data, generatorFactory: generatorFactory);

            AssertText(writer.Document, @"
                Item
                þ Milk
                þ Eggs
                ¨ Artisan Bread

                ");

            Assert.AreEqual(4, writer.Document.SelectNodes("//Row").Count, "The row should be repeated for each item.");
            Assert.AreEqual(4, writer.Document.SelectNodes("//Cell").Count, "The cell should be repeated in each row.");
        }
Beispiel #7
0
        public void MergeDocText_ListThatSpanParagraphsNonStandard_MergeRepeatedPerItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"^{{ each TimeZones }}
                {{ Name }}{{ end each }}$");

            var data = new
            {
                TimeZones = new[] {
                        new {Name = "Eastern" },
                        new {Name = "Central" },
                        new {Name = "Mountain West" },
                        new {Name = "Pacific" },
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"^
                            Eastern
                            Central
                            Mountain West
                            Pacific$
                            ");
        }
Beispiel #8
0
        public void MergeDocText_ListInTable_RowIsRemovedIfTagOnly()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                      | In Stock      | Price          |
                | ------------------------- | ------------- | -------------- |
                | {{ each Items }}                                           |
                | {{ if Group }}{{ Group }}                                  |
                | {{ else }}None                                             |
                | {{ end if }}                                               |
                | {{ Name }}                | {{ InStock }} | {{ Price }}    |
                | {{ end each }}                                             |

                ");

            var data = new
            {
                Items = new[] {
                        new {Group = "Dairy", Name = "Milk", InStock = true, Price = 3.50 },
                        new {Group = "Dairy", Name = "Eggs", InStock = true, Price = 2.25 },
                        new {Group = "", Name = "Artisan Bread", InStock = false, Price = 6.99 }
                    },
            };

            writer.Document.Merge(data);

            writer.Document.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                      </Paragraph>
                      <Table preferredwidth='Auto'>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Item</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>In Stock</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Price</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Dairy</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Milk</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>True</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>3.5</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Dairy</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Eggs</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>True</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>2.25</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>None</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Artisan Bread</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>False</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>6.99</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                      </Table>
                      <Paragraph>
                      </Paragraph>
                      <Paragraph>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");
        }
Beispiel #9
0
        public void MergeDocText_IfHasValue_BlockIsRendered()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"{{ if Recipients }}To: {{ each Recipients }}{{ Name }}, {{ end each }} Subject: {{ Title }}{{ end if }}");

            var data = new
            {
                Title = "Information About Your Policy",
                Recipients = new[] {
                        new {Name = "Jane Doe" },
                        new {Name = "Jon Doe" },
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"To: Jane Doe, Jon Doe,  Subject: Information About Your Policy
                           ");
        }
Beispiel #10
0
        public void MergeDocText_IfFalseValue_MultipleBlocksAreNotRendered()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"^
                                    {{ if ShouldSendOffer }}
                                    To: {{ Recipient }}
                                    {{ end if }}
                                    $");

            var data = new
            {
                Title = "Free Vacation Offer",
                ShouldSendOffer = false,
                Recipient = "Valued Customer",
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"^
                            $
                            ");
        }
Beispiel #11
0
        public void MergeDocText_TableWithConditionals_RowRemainsIfOtherContent()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                                      | In Stock |
                | -----------------------------------       | -------- |
                | {{ if Name }}{{ Name }}{{ end if }}&nbsp; | Yes      |

                ");

            var data = new
            {
                Name = "",
                InStock = "",
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"

                | Item   | In Stock |
                | ----   | -------- |
                | &nbsp; | Yes      |

                ", asMarkdown: true);

            Assert.AreEqual(2, writer.Document.SelectNodes("//Row").Count, "The row should be repeated for each item.");
            Assert.AreEqual(4, writer.Document.SelectNodes("//Cell").Count, "The cells should be repeated in each row.");
        }
Beispiel #12
0
        public void MergeDocText_TableWithConditionals_EmptyRowPreserved()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                                | In Stock                                  |
                | ----------------------------------- | ----------------------------------------- |
                | {{ if Name }}{{ Name }}{{ end if }} | {{ if InStock }}{{ InStock }}{{ end if }} |

                ");

            var data = new
            {
                Name = "",
                InStock = "",
            };

            writer.Document.Merge(data);

            writer.Document.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                      </Paragraph>
                      <Table preferredwidth='Auto'>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Item</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>In Stock</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                          </Cell>
                          <Cell>
                          </Cell>
                        </Row>
                      </Table>
                      <Paragraph>
                      </Paragraph>
                      <Paragraph>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");
        }
Beispiel #13
0
        public void MergeDocText_ListWithErrors_MergeRepeatedPerItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"^{{ each TimeZones }}
                {{ Name }} - {{ $foo }}{{ end each }}$");

            var data = new
            {
                TimeZones = new[] {
                        new {Name = "Eastern" },
                        new {Name = "Central" },
                        new {Name = "Mountain West" },
                        new {Name = "Pacific" },
                    },
            };

            IMergeError[] errors;

            writer.Document.TryMerge(data, out errors);

            AssertText(writer.Document, @"^
                            Eastern - {{ $foo }}
                            Central - {{ $foo }}
                            Mountain West - {{ $foo }}
                            Pacific - {{ $foo }}$
                            ");
        }
Beispiel #14
0
        public void MergeDocText_ListWithEmptyParagraphs_EmptyParagraphsPreserved()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"^
                {{ each CardinalDirections }}

                {{ Symbol }}

                {{ Name }}
                {{ end each }}

                $");

            var data = new
            {
                CardinalDirections = new[] {
                        new {Name = "North", Symbol='↑' },
                        new {Name = "South", Symbol='↓' },
                        new {Name = "East", Symbol='→' },
                        new {Name = "West", Symbol='←' },
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"^

                            ↑

                            North

                            ↓

                            South

                            →

                            East

                            ←

                            West

                            $
                            ");
        }
Beispiel #15
0
        public void MergeDocText_ListInTableWithBlankValues_RowRemains()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                       | In Stock      | Price                     |
                | -------------------------- | ------------- | ------------------------- |
                | {{ each Items }}{{ Name }} | {{ InStock }} | {{ Price }}{{ end each }} |

                ");

            var data = new
            {
                Items = new[]
                {
                    new {Name = "", InStock = "", Price = ""},
                },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"

                | Item   | In Stock | Price  |
                | ----   | -------- | -----  |
                | &nbsp; | &nbsp;   | &nbsp; |
                ", asMarkdown: true);

            Assert.AreEqual(2, writer.Document.SelectNodes("//Row").Count, "The row should be repeated for each item.");
            Assert.AreEqual(6, writer.Document.SelectNodes("//Cell").Count, "The cells should be repeated in each row.");
        }
Beispiel #16
0
        public void MergeDocText_ListInTable_RowIsRemovedIfNoItems()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                       | In Stock      | Price                     |
                | -------------------------- | ------------- | ------------------------- |
                | {{ each Items }}{{ Name }} | {{ InStock }} | {{ Price }}{{ end each }} |

                ");

            var data = new
            {
                Items = new object[0],
            };

            writer.Document.Merge(data);

            writer.Document.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                      </Paragraph>
                      <Table preferredwidth='Auto'>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Item</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>In Stock</Run>
                            </Paragraph>
                          </Cell>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Price</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                      </Table>
                      <Paragraph>
                      </Paragraph>
                      <Paragraph>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");

            AssertText(writer.Document, @"

                | Item                       | In Stock      | Price                     |
                | -------------------------- | ------------- | ------------------------- |

                ", asMarkdown: true);

            Assert.AreEqual(1, writer.Document.SelectNodes("//Row").Count, "Only the header row should remain.");
            Assert.AreEqual(3, writer.Document.SelectNodes("//Cell").Count, "Only the header cells should remain.");
        }
Beispiel #17
0
        public void MergeDocText_IfWithinList_BlockIsRenderedWhenConditionPasses()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"{{ each NcaaConferences }}{{ if Active }}{{ Name }}, {{ end if }}{{ end each }}");

            var data = new
            {
                NcaaConferences = new[] {
                        new {Name = "PAC 12", Active = true },
                        new {Name = "SEC", Active = true },
                        new {Name = "Big East", Active = false }
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"PAC 12, SEC,
                           ");
        }
Beispiel #18
0
        public void MergeDocText_ListInTable_RowIsRepeatedForEachItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Item                       | In Stock      | Price                     |
                | -------------------------- | ------------- | ------------------------- |
                | {{ each Items }}{{ Name }} | {{ InStock }} | {{ Price }}{{ end each }} |

                ");

            var data = new
            {
                Items = new[] {
                        new {Name = "Milk", InStock = true, Price = 3.50 },
                        new {Name = "Eggs", InStock = true, Price = 2.25 },
                        new {Name = "Artisan Bread", InStock = false, Price = 6.99 }
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"
                Item
                In Stock
                Price
                Milk
                True
                3.5
                Eggs
                True
                2.25
                Artisan Bread
                False
                6.99

                ");

            Assert.AreEqual(4, writer.Document.SelectNodes("//Row").Count, "The row should be repeated for each item.");
            Assert.AreEqual(12, writer.Document.SelectNodes("//Cell").Count, "The cells should be repeated in each row.");
        }
Beispiel #19
0
        public void MergeDocText_IfWithMultipleOptions_SatsifyingBlockIsRendered()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"^
                                    {{ Title }}
                                    {{ if ShouldSendOffer }}
                                    To: {{ Recipient }}
                                    {{ else if IsUnderReview }}
                                    Status: <UNDER_REVIEW>
                                    {{ else }}
                                    Status: <UNKNOWN>
                                    {{ end if }}
                                    $");

            var data = new
            {
                Title = "Free Vacation Offer",
                IsUnderReview = true,
                ShouldSendOffer = false,
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"^
                            Free Vacation Offer
                            Status: <UNDER_REVIEW>
                            $
                            ");
        }
Beispiel #20
0
        public void MergeDocText_ListInMultiRowTable_EmptyRowsRemoved()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"

                | Items                      |
                | -------------------------- |
                | {{ each Items }}{{ Name }} |
                | {{ InStock }}              |
                | {{ Price }}{{ end each }}  |

                ");

            var data = new
            {
                Items = new object[0],
            };

            writer.Document.Merge(data);

            writer.Document.AssertXml(@"
                <Document>
                  <Section>
                    <Body>
                      <Paragraph>
                      </Paragraph>
                      <Table preferredwidth='Auto'>
                        <Row rowformat_preferredwidth='Auto'>
                          <Cell>
                            <Paragraph paragraphformat_spaceafter='6' paragraphformat_stylename='Body Text' paragraphformat_styleidentifier='BodyText'>
                              <Run>Items</Run>
                            </Paragraph>
                          </Cell>
                        </Row>
                      </Table>
                      <Paragraph>
                      </Paragraph>
                      <Paragraph>
                      </Paragraph>
                    </Body>
                  </Section>
                </Document>
                ");

            Assert.AreEqual(1, writer.Document.SelectNodes("//Row").Count, "The header row should be the only one remaining.");
            Assert.AreEqual(1, writer.Document.SelectNodes("//Cell").Count, "There should be one cell per row.");
        }
Beispiel #21
0
        public void MergeDocText_ListThatSpanParagraphs_MergeRepeatedPerItem()
        {
            var writer = new DocumentTemplateWriter();

            writer.InsertMarkdown(@"^
                {{ each SportsLeagues }}
                {{ Acronym }}
                {{ end each }}
                $");

            var data = new
            {
                SportsLeagues = new[] {
                        new {Acronym = "MLB" },
                        new {Acronym = "NBA" },
                        new {Acronym = "NFL" },
                        new {Acronym = "NHL" },
                        new {Acronym = "MLS" },
                    },
            };

            writer.Document.Merge(data);

            AssertText(writer.Document, @"^
                            MLB
                            NBA
                            NFL
                            NHL
                            MLS
                            $
                            ");
        }