public void Subset() { XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(@" <root> <element1 attr2='2'> <uhus/> </element1> </root> " ); XmlDocument doc2 = new XmlDocument(); doc2.LoadXml(@" <root> <element1 attr1='1' attr2='2'> <subelement1>uhus</subelement1> <uhus/> </element1> </root> " ); NavigatorUtils.IsSubsetOf(doc1.CreateNavigator(), doc2.CreateNavigator()); }
public void ExtraSubSubelement() { XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(@" <root> <element1 attr1='1' attr2='b'> <subelement1>uhus</subelement1> </element1> </root> " ); XmlDocument doc2 = new XmlDocument(); doc2.LoadXml(@" <root> <element1 attr1='1' attr2='b'> <subelement1>uhus <subelement2 a='a'/> </subelement1> </element1> </root> " ); NavigatorUtils.AreEqual(doc1.CreateNavigator(), doc2.CreateNavigator()); }
private static void SerializeAndCompare(object o) { XPathNavigator nav1 = NavigatorUtils.Serialize(o); ObjectXPathContext context = new ObjectXPathContext(); context.NamespaceManager.AddNamespace("sdf", Namespaces.SDF); XPathNavigator nav2 = context.CreateNavigator(o); NavigatorUtils.PrintNavigator(nav2); nav2.MoveToRoot(); NavigatorUtils.AreEqual(nav2, nav1); }
public static void IsSubset(object o, string xml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); ObjectXPathContext context = new ObjectXPathContext(); context.NamespaceManager.AddNamespace("sdf", Namespaces.SDF); XPathNavigator nav = context.CreateNavigator(o); nav.MoveToRoot(); NavigatorUtils.IsSubsetOf(doc.CreateNavigator(), nav); }
public void EqualNavigators() { XmlDocument doc = new XmlDocument(); doc.LoadXml(@" <root xmlns:u='uuu'> <u:element1 attr1='1' attr2='b'> <subelement1>uhus</subelement1> <!-- uhus was here --> </u:element1> </root> <!-- and here --> " ); NavigatorUtils.AreEqual(doc.CreateNavigator(), doc.CreateNavigator()); }
public static void Compare(object o, string xml) { XmlDocument doc = new XmlDocument(); doc.LoadXml(xml); ObjectXPathContext context = new ObjectXPathContext(); context.NamespaceManager.AddNamespace("sdf", Namespaces.SDF); XPathNavigator nav = context.CreateNavigator(o); nav.MoveToRoot(); /*NavigatorUtils.PrintNavigator( nav ); * * nav.MoveToRoot();*/ NavigatorUtils.AreEqual(nav, doc.CreateNavigator()); }
public void NoElementInFirst() { XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(@" <root> </root> " ); XmlDocument doc2 = new XmlDocument(); doc2.LoadXml(@" <root> <element1 attr1='1'> <subelement1>uhus</subelement1> </element1> </root> " ); NavigatorUtils.AreEqual(doc1.CreateNavigator(), doc2.CreateNavigator()); }
private static void DeserializeAndCompare(object o) { ObjectXPathContext context = new ObjectXPathContext(); context.NamespaceManager.AddNamespace("sdf", Namespaces.SDF); XPathNavigator nav = context.CreateNavigator(o); nav.MoveToRoot(); NavigatorUtils.PrintNavigator(nav); nav.MoveToRoot(); // object o2 = Deserialize( o.GetType(), nav ); object o2 = NavigatorUtils.Deserialize(o.GetType(), NavigatorUtils.Serialize(o)); XPathNavigator nav2 = context.CreateNavigator(o2); nav2.MoveToRoot(); nav.MoveToRoot(); NavigatorUtils.AreEqual(nav, nav2); }
public void DiffrentNamespaces() { XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(@" <root xmlns:u='uuu'> <u:element1 attr1='1' attr2='b'> <subelement1>uhus</subelement1> </u:element1> </root> " ); XmlDocument doc2 = new XmlDocument(); doc2.LoadXml(@" <root xmlns:u='uuu1'> <u:element1 attr1='1' attr2='b'> <subelement1>uhus</subelement1> </u:element1> </root> " ); NavigatorUtils.AreEqual(doc1.CreateNavigator(), doc2.CreateNavigator()); }
public void DiffrentValue() { XmlDocument doc1 = new XmlDocument(); doc1.LoadXml(@" <root> <element1 attr1='1' attr2='b'> <subelement1>uhus</subelement1> </element1> </root> " ); XmlDocument doc2 = new XmlDocument(); doc2.LoadXml(@" <root> <element1 attr1='1' attr2='b'> <subelement1>juja</subelement1> </element1> </root> " ); NavigatorUtils.AreEqual(doc1.CreateNavigator(), doc2.CreateNavigator()); }