public void TestParse()
 {
     using (var docStream = AssemblyResourceHelper.GetResourceStream(this, "HtmlContentParserTest.xml"))
     {
         var doc = XDocument.Load(docStream);
         var processorMock = new TagProcessorMock<HtmlContentProcessor>();
         var parser = new HtmlContentParser();
         parser.Parse(processorMock, doc.Descendants(WordMl.SdtName).First());
         var processor = processorMock.InnerProcessor;
         var tag = processor.HtmlTag;
         Assert.IsNotNull(tag);
         Assert.AreEqual("//test/htmlcontent", tag.Expression);
     }
 }
        public void TestParseMissingEndTableTag()
        {
            var processorMock = new TagProcessorMock<TableProcessor>();
            var parser = new TableParser();

            var root = new XElement(this.documentRoot);
            TraverseUtils.TagElement(root, "EndTable").Remove();
            var startElement = TraverseUtils.TagElement(root, "Table");
            parser.Parse(processorMock, startElement);
        }
        public void TestParseVariousOrderTag()
        {
            var processorMock = new TagProcessorMock<TableProcessor>();
            var parser = new TableParser();

            var root = new XElement(this.documentRoot);
            var paragraph = root.Element(WordMl.ParagraphName);
            //var itemsElement = TraverseUtils.TagElement(root, "Items");
            //itemsElement.AddBeforeSelf(paragraph);
            //var dynamicRowElement = TraverseUtils.TagElement(root, "DynamicRow");
            //dynamicRowElement.AddBeforeSelf(paragraph);
            //var contentElement = TraverseUtils.TagElement(root, "Content");
            //contentElement.AddBeforeSelf(paragraph);
            //var endContentElement = TraverseUtils.TagElement(root, "EndContent");
            //endContentElement.AddBeforeSelf(paragraph);
            var tableElement = root.Element(WordMl.TableName);
            Assert.IsNotNull(tableElement);
            tableElement.AddBeforeSelf(paragraph);
            var endTableElement = TraverseUtils.TagElement(root, "EndTable");
            endTableElement.AddBeforeSelf(paragraph);
            var startElement = TraverseUtils.TagElement(root, "Table");

            parser.Parse(processorMock, startElement);
            var processor = processorMock.InnerProcessor;
            var tag = processor.TableTag;
            Assert.AreEqual(4, tag.DynamicRow);
            Assert.AreEqual("//test/certificates", tag.ItemsSource);
            Assert.AreEqual(tableElement, tag.Table);
            this.CheckTagElements(tag);

          //  itemsElement.Remove();
            //endTableElement.AddBeforeSelf(itemsElement);

            parser.Parse(processorMock, startElement);
            processor = processorMock.InnerProcessor;
            tag = processor.TableTag;
            Assert.AreEqual(4, tag.DynamicRow);
            Assert.AreEqual("//test/certificates", tag.ItemsSource);
            Assert.AreEqual(tableElement, tag.Table);
            this.CheckTagElements(tag);

            //dynamicRowElement.Remove();
            //endTableElement.AddBeforeSelf(dynamicRowElement);

            parser.Parse(processorMock, startElement);
            processor = processorMock.InnerProcessor;
            tag = processor.TableTag;
            Assert.AreEqual(4, tag.DynamicRow);
            Assert.AreEqual("//test/certificates", tag.ItemsSource);
            Assert.AreEqual(tableElement, tag.Table);
            this.CheckTagElements(tag);

            //contentElement.Remove();
            tableElement.Remove();
            //endContentElement.Remove();
            //endTableElement.AddBeforeSelf(contentElement);
            endTableElement.AddBeforeSelf(tableElement);
            //endTableElement.AddBeforeSelf(endContentElement);

            parser.Parse(processorMock, startElement);
            processor = processorMock.InnerProcessor;
            tag = processor.TableTag;
            Assert.AreEqual(4, tag.DynamicRow);
            Assert.AreEqual("//test/certificates", tag.ItemsSource);
            Assert.AreEqual(tableElement, tag.Table);
            this.CheckTagElements(tag);
        }
        public void TestOkay()
        {
            var parser = new RepeaterParser();
            var tagProcessorMock = new TagProcessorMock<RepeaterProcessor>();
            parser.Parse(tagProcessorMock, this.documentRoot.Descendants(WordMl.SdtName).First());

            var result = tagProcessorMock.InnerProcessor.RepeaterTag;

            var repeaterElements = 
                TraverseUtils.ElementsBetween(result.StartRepeater, result.EndRepeater)
                             .Select(result.MakeElementCallback).ToList();
            Assert.AreEqual(1, repeaterElements.Count);

            var childrenOfFirstElement = repeaterElements.First().Elements.ToList();
            Assert.AreEqual(9, childrenOfFirstElement.Count);
            Assert.AreEqual("./Subject", childrenOfFirstElement[3].Expression);
            Assert.AreEqual(true, childrenOfFirstElement[5].IsIndex);
            Assert.AreEqual("./ExpireDate", childrenOfFirstElement[7].Expression);
            Assert.AreEqual("//test/certificates", result.Source);
        }