Beispiel #1
0
        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());
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
        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);
        }
Beispiel #5
0
        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());
        }
Beispiel #6
0
        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());
        }
Beispiel #7
0
        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());
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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());
        }
Beispiel #10
0
        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());
        }