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))); }
public void GetNodeToMerge_WithDoubleQuoteInAttribute_FindsIt() { string xml = @"<lift> <entry id='she said "Hi!"' /> </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); }
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\"]"); }