public void FindsNothingInNullList()
 {
     var doc = new XmlDocument();
     var target = XmlUtilities.GetDocumentNodeFromRawXml(@"<b/>", doc);
     var finder = new FindByKeyAttributeInList("key");
     Assert.That(finder.GetNodeToMerge(target, null, new HashSet<XmlNode>()), Is.Null);
 }
 public void FindsUniqueMatch()
 {
     var doc = new XmlDocument();
     var parent = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='one'/><b key='two'/></a>", doc);
     var target = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='two'/></a>", doc).FirstChild;
     var finder = new FindByKeyAttributeInList("key");
     Assert.That(finder.GetNodeToMerge(target, parent, SetFromChildren.Get(parent)), Is.EqualTo(parent.ChildNodes[1]));
 }
 public void FindsNothingWithNoKey()
 {
     var doc = new XmlDocument();
     var parent = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='one'/></a>", doc);
     var target = XmlUtilities.GetDocumentNodeFromRawXml(@"<b/>", doc);
     var finder = new FindByKeyAttributeInList("key");
     Assert.That(finder.GetNodeToMerge(target, parent, SetFromChildren.Get(parent)), Is.Null);
 }
 public void FindsNoMatchWhereTooFewOccurrences()
 {
     var doc = new XmlDocument();
     var parent = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='one'/><b key='two'/></a>", doc);
     var target = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='one'/><b key='one'/></a>", doc).ChildNodes[1];
     var finder = new FindByKeyAttributeInList("key");
     Assert.That(finder.GetNodeToMerge(target, parent, SetFromChildren.Get(parent)), Is.Null);
 }
 public void FindsSecondDuplicateWhereFirstNotAcceptable()
 {
     var doc = new XmlDocument();
     var parent = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='one'/><b key='two'/><b key='two'/></a>", doc);
     var target = XmlUtilities.GetDocumentNodeFromRawXml(@"<a><b key='one'/><b key='two'/></a>", doc).ChildNodes[1];
     var desiredResult = parent.ChildNodes[2];
     var otherOption = parent.ChildNodes[1]; // acceptable but not matching
     var acceptableTargets = new HashSet<XmlNode>(new [] {otherOption, desiredResult});
     var finder = new FindByKeyAttributeInList("key");
     Assert.That(finder.GetNodeToMerge(target, parent, acceptableTargets), Is.EqualTo(parent.ChildNodes[2]));
 }