示例#1
0
        public void GetNodeToMerge_WithoutKeyAttr_ReturnsNull()
        {
            const string xml =
                @"<a>
                    <b />
                </a>";

            var doc1 = new XmlDocument();
            doc1.LoadXml(xml);

            var finder = new FindByKeyAttribute("id");
            var node = doc1.SelectSingleNode("//b");
            Assert.IsNull(finder.GetNodeToMerge(node, doc1.DocumentElement, SetFromChildren.Get(doc1.DocumentElement)));
        }
示例#2
0
        public void GetNodeToMerge_WithDoubleQuoteInAttribute_FindsIt()
        {
            string xml =
                @"<lift>
                    <entry id='she said &quot;Hi!&quot;' />
                </lift>";

            var doc1 = new XmlDocument();
            doc1.LoadXml(xml);

            var finder = new FindByKeyAttribute("id");
            var node = doc1.SelectSingleNode("//entry");
            var result = finder.GetNodeToMerge(node, doc1.DocumentElement, SetFromChildren.Get(doc1.DocumentElement));
            Assert.AreEqual(node,result);
        }
示例#3
0
        public void GetNodeToMerge_ReturnsNode()
        {
            string xml =
                @"<lift>
                    <entry id='test' />
                </lift>";

            var doc1 = new XmlDocument();
            doc1.LoadXml(xml);

            var finder = new FindByKeyAttribute("id");
            var node = doc1.SelectSingleNode("//entry");
            var result = finder.GetNodeToMerge(node, doc1.DocumentElement, SetFromChildren.Get(doc1.DocumentElement));
            Assert.NotNull(result);
            XmlTestHelper.AssertXPathMatchesExactlyOne(result, "entry[@id=\"test\"]");
        }