public void TestParseXml(string s, List <TextElement> expectedResult)
        {
            var reader = XmlUtils.CreateReader(s);
            var parser = new TextContentParser();

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    Assert.True(parser.AddElement(reader));
                }
            }

            CompareResult(parser.Result, expectedResult);
        }
        public void TestInvalidXml(string s, List <TextElement> expectedResult)
        {
            var reader = XmlUtils.CreateReader(s);
            var parser = new TextContentParser();

            if (expectedResult == null)
            {
                Assert.Throws <ArgumentException>(() =>
                {
                    while (reader.Read())
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            parser.AddElement(reader);
                        }
                    }
                });
            }
            else
            {
                var anyWrong = false;

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element)
                    {
                        if (!parser.AddElement(reader))
                        {
                            anyWrong = true;
                        }
                    }
                }

                Assert.True(anyWrong);

                CompareResult(parser.Result, expectedResult);
            }
        }