public void FindAbstractNumId_Test()
        {
            var instance = new NumberItemFactory
            {
                Numbering = DocumentSample1.GenerateNumbering()
            };

            var result = instance.FindAssociatedAbstractNumId(1);

            Assert.AreEqual(0, result);
        }
示例#2
0
 private void MockDocument()
 {
     _wpDoc = WordprocessingDocument.Create(
         new MemoryStream(),
         DocumentFormat.OpenXml.WordprocessingDocumentType.Document);
     _wpDoc.AddMainDocumentPart();
     _wpDoc.MainDocumentPart.AddNewPart <NumberingDefinitionsPart>();
     _wpDoc.MainDocumentPart.AddNewPart <StyleDefinitionsPart>();
     _wpDoc.MainDocumentPart.Document =
         new Document(
             DocumentSample1.GenerateBody());
     _wpDoc.MainDocumentPart.NumberingDefinitionsPart.Numbering =
         DocumentSample1.GenerateNumbering();
     _wpDoc.MainDocumentPart.StyleDefinitionsPart.Styles =
         DocumentSample1.GenerateStyles();
 }
示例#3
0
        public void CreateCache_StairsTest()
        {
            var body     = DocumentSample2.GenerateBody();
            var instance = new ParagraphStateCacheFactory
            {
                Body      = body,
                Numbering = DocumentSample1.GenerateNumbering()
            };
            var cache = instance.Create();

            var ps      = body.Elements <Paragraph>().ToArray();
            var results = ps.Select(cache.Get).ToArray();

            for (int i = 0; i < results.Length; i++)
            {
                var textSplits      = ps[i].InnerText.Split(' ').Select(int.Parse).ToArray();
                var expectedLevel   = textSplits[0];
                var expectedLastVal = textSplits[1] + 1;

                Assert.AreEqual(expectedLevel, results[i].Indentations.Count());
                Assert.AreEqual(expectedLastVal, results[i].Indentations.Last());
            }
        }
示例#4
0
        public void CreateCache_Test()
        {
            var body     = DocumentSample1.GenerateBody();
            var instance = new ParagraphStateCacheFactory
            {
                Styles    = DocumentSample1.GenerateStyles(),
                Body      = body,
                Numbering = DocumentSample1.GenerateNumbering()
            };

            var cache = instance.Create();

            var ps1 = body.Elements <Paragraph>().Take(3).ToArray();

            AssertNumbering(cache.Get(ps1[0]), 1, 1);
            AssertNumbering(cache.Get(ps1[1]), 2, 1);
            AssertNumbering(cache.Get(ps1[2]), 1, 2);

            var ps2 = body.Elements <Paragraph>().Skip(6).ToArray();

            AssertNumbering(cache.Get(ps2[0]), 2, 2);
            AssertNumbering(cache.Get(ps2[1]), 2, 3);
            AssertNumbering(cache.Get(ps2[2]), 2, 4);
        }