示例#1
0
		public void ShouldMatchStartElementCloseOnLastAttribute()
		{
			XmlReader reader = GetReader("<root id='1' title='foo'></root>");
			ElementMatch match = new ElementMatch("root", MatchMode.StartElementClosed);

			reader.MoveToContent();

			Assert.IsFalse(match.Matches(reader, null));
			reader.MoveToFirstAttribute();
			Assert.IsFalse(match.Matches(reader, null));
			reader.MoveToNextAttribute();
			Assert.IsTrue(match.Matches(reader, null));
		}
示例#2
0
        public void WildcardNameDoesNotMatchWrongElementNamespace()
        {
            XmlMatch  match  = new ElementMatch("*");
            XmlReader reader = GetReader("<foo xmlns='mvp-xml'><bar xmlns=''/></foo>");

            reader.MoveToContent();

            Assert.IsFalse(match.Matches(reader, null));

            reader.Read();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#3
0
        public void WildcardNameMatchesAnyElement()
        {
            XmlMatch  match  = new ElementMatch("*");
            XmlReader reader = GetReader("<foo><bar/></foo>");

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));

            reader.Read();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#4
0
        public void WildcardNamespaceMatchesElementsInAnyNamespace()
        {
            XmlMatch  match  = new ElementMatch("*", "foo");
            XmlReader reader = GetReader("<foo><foo xmlns='mvp-xml'/></foo>");

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));

            reader.Read();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#5
0
        public void ShouldMatchStartElementCloseOnLastAttribute()
        {
            XmlReader    reader = GetReader("<root id='1' title='foo'></root>");
            ElementMatch match  = new ElementMatch("root", MatchMode.StartElementClosed);

            reader.MoveToContent();

            Assert.IsFalse(match.Matches(reader, null));
            reader.MoveToFirstAttribute();
            Assert.IsFalse(match.Matches(reader, null));
            reader.MoveToNextAttribute();
            Assert.IsTrue(match.Matches(reader, null));
        }
示例#6
0
        public void BothWildcardMatchesAnyElementAndNamespace()
        {
            XmlMatch  match  = new ElementMatch("*", "*");
            XmlReader reader = GetReader("<foo><bar xmlns='xml-mvp'/></foo>");

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));

            reader.Read();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#7
0
        public void MatchCanReceiveNullResolver()
        {
            XmlMatch  match  = new ElementMatch("foo");
            XmlReader reader = GetReader("<foo/>");

            match.Matches(reader, null);
        }
示例#8
0
        public void DoesNotMatchWrongLocalName()
        {
            XmlMatch  match  = new ElementMatch("foo");
            XmlReader reader = GetReader("<root><foo/></root>");

            reader.MoveToContent();

            Assert.IsFalse(match.Matches(reader, null));

            match = new ElementMatch("foo", MatchMode.EndElement);
            reader.Read();
            Assert.IsFalse(match.Matches(reader, null));
            reader.Read();
            Assert.IsTrue(match.Matches(reader, null));
            reader.Read();
            Assert.IsFalse(match.Matches(reader, null));
        }
示例#9
0
        public void WildcardNameMatchesAnyElementWithPrefix()
        {
            XmlMatch  match  = new ElementMatch("x", "*");
            XmlReader reader = GetReader("<x:foo xmlns:x='xml-mvp'><x:bar/></x:foo>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            ns.AddNamespace("x", "xml-mvp");

            Assert.IsTrue(match.Matches(reader, ns));

            reader.Read();

            Assert.IsTrue(match.Matches(reader, ns));
        }
示例#10
0
		public void ShouldMatchStartElementCloseIfNoAttributes()
		{
			XmlReader reader = GetReader("<root></root>");
			ElementMatch match = new ElementMatch("root", MatchMode.StartElementClosed);

			reader.MoveToContent();

			Assert.IsTrue(match.Matches(reader, null));
		}
示例#11
0
		public void ShouldMatchElementForRootToo()
		{
			XmlReader reader = GetReader("<root/>");
			ElementMatch match = new ElementMatch("root", MatchMode.StartElement);

			reader.MoveToContent();

			Assert.IsTrue(match.Matches(reader, null));
		}
示例#12
0
        public void MatchThrowsIfPrefixButNoResolver()
        {
            XmlMatch  match  = new ElementMatch("foo", "bar");
            XmlReader reader = GetReader("<foo:bar xmlns:foo='xml-mvp'/>");

            reader.MoveToContent();

            match.Matches(reader, null);
        }
示例#13
0
        public void ThrowsIfWildcardNameWithPrefixAndNoResolver()
        {
            XmlMatch  match  = new ElementMatch("x", "*");
            XmlReader reader = GetReader("<x:foo xmlns:x='xml-mvp'><x:bar/></x:foo>");

            reader.MoveToContent();

            match.Matches(reader, null);
        }
示例#14
0
        public void ShouldMatchElementForRootToo()
        {
            XmlReader    reader = GetReader("<root/>");
            ElementMatch match  = new ElementMatch("root", MatchMode.StartElement);

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#15
0
        public void ShouldMatchStartElementCloseIfNoAttributes()
        {
            XmlReader    reader = GetReader("<root></root>");
            ElementMatch match  = new ElementMatch("root", MatchMode.StartElementClosed);

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#16
0
		public void ShouldMatchElement()
		{
			XmlReader reader = GetReader("<root><foo></foo></root>");
			ElementMatch match = new ElementMatch("foo", MatchMode.StartElement);

			reader.MoveToContent();
			reader.Read();

			Assert.IsTrue(match.Matches(reader, null));
		}
示例#17
0
        public void ElementMatchOptionDoesNotMatchEndElement()
        {
            XmlMatch  match  = new ElementMatch("bar");
            XmlReader reader = GetReader("<bar></bar>");

            reader.MoveToContent();
            reader.Read();

            Assert.IsFalse(match.Matches(reader, null));
        }
示例#18
0
        public void EndElementMatchOptionMatchesEndElement()
        {
            XmlMatch  match  = new ElementMatch("bar", MatchMode.EndElement);
            XmlReader reader = GetReader("<bar></bar>");

            reader.MoveToContent();
            reader.Read();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#19
0
        public void ShouldMatchElement()
        {
            XmlReader    reader = GetReader("<root><foo></foo></root>");
            ElementMatch match  = new ElementMatch("foo", MatchMode.StartElement);

            reader.MoveToContent();
            reader.Read();

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#20
0
        public void ThrowsIfPrefixUnresolvable()
        {
            XmlMatch  match  = new ElementMatch("foo", "bar");
            XmlReader reader = GetReader("<bar/>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            match.Matches(reader, ns);
        }
示例#21
0
        public void MatchesNameWithPrefixDocumentWithoutPrefixButNamespace()
        {
            XmlMatch  match  = new ElementMatch("foo", "bar");
            XmlReader reader = GetReader("<bar xmlns='xml-mvp'/>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            ns.AddNamespace("foo", "xml-mvp");

            Assert.IsTrue(match.Matches(reader, ns));
        }
示例#22
0
        public void DoesNotMatchSameLocalNameButWrongNamespace2()
        {
            XmlMatch  match  = new ElementMatch("foo", "bar");
            XmlReader reader = GetReader("<bar/>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            ns.AddNamespace("foo", "xml-mvp");

            Assert.IsFalse(match.Matches(reader, ns));
        }
示例#23
0
        public void CanResolveToEmptyNamespace()
        {
            XmlMatch  match  = new ElementMatch("foo", "bar");
            XmlReader reader = GetReader("<bar/>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            ns.AddNamespace("foo", String.Empty);

            Assert.IsTrue(match.Matches(reader, ns));
        }
示例#24
0
        public void ThrowsIfWildcardNameCannotResolvePrefix()
        {
            XmlMatch  match  = new ElementMatch("x", "*");
            XmlReader reader = GetReader("<x:foo xmlns:x='xml-mvp'><x:bar/></x:foo>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            ns.AddNamespace("y", "xml-mvp");

            match.Matches(reader, ns);
        }
示例#25
0
        public void MatchesLocalNameWithoutPrefix()
        {
            XmlMatch  match  = new ElementMatch("foo");
            XmlReader reader = GetReader("<foo></foo>");

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));

            reader.Read();
            match = new ElementMatch("foo", MatchMode.EndElement);

            Assert.IsTrue(match.Matches(reader, null));
        }
示例#26
0
        public void MatchesNameWithPrefix()
        {
            XmlMatch  match  = new ElementMatch("foo", "bar");
            XmlReader reader = GetReader("<foo:bar xmlns:foo='xml-mvp'></foo:bar>");

            reader.MoveToContent();

            XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

            ns.AddNamespace("foo", "xml-mvp");

            Assert.IsTrue(match.Matches(reader, ns));

            reader.Read();

            match = new ElementMatch("foo", "bar", MatchMode.EndElement);
            Assert.IsTrue(match.Matches(reader, ns));
        }
示例#27
0
        public void ElementMatchOptionMatchesOnlyElement()
        {
            XmlMatch  match  = new ElementMatch("id");
            XmlReader reader = GetReader("<bar id='23'>hello</bar>");

            reader.MoveToContent();
            reader.MoveToFirstAttribute();

            Assert.IsFalse(match.Matches(reader, null));

            match = new ElementMatch("hello");
            reader.MoveToElement();
            reader.Read();

            Assert.AreEqual(XmlNodeType.Text, reader.NodeType);

            Assert.IsFalse(match.Matches(reader, null));
        }
示例#28
0
		public void ThrowsIfWildcardNameWithPrefixAndNoResolver()
		{
			XmlMatch match = new ElementMatch("x", "*");
			XmlReader reader = GetReader("<x:foo xmlns:x='xml-mvp'><x:bar/></x:foo>");
			reader.MoveToContent();

			match.Matches(reader, null);
		}
示例#29
0
		public void MatchThrowsIfPrefixButNoResolver()
		{
			XmlMatch match = new ElementMatch("foo", "bar");
			XmlReader reader = GetReader("<foo:bar xmlns:foo='xml-mvp'/>");
			reader.MoveToContent();

			match.Matches(reader, null);
		}
示例#30
0
		public void MatchesNameWithPrefix()
		{
			XmlMatch match = new ElementMatch("foo", "bar");
			XmlReader reader = GetReader("<foo:bar xmlns:foo='xml-mvp'></foo:bar>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);
			ns.AddNamespace("foo", "xml-mvp");

			Assert.IsTrue(match.Matches(reader, ns));

			reader.Read();

			match = new ElementMatch("foo", "bar", MatchMode.EndElement);
			Assert.IsTrue(match.Matches(reader, ns));
		}
示例#31
0
		public void WildcardNameMatchesAnyEndElement()
		{
		    XmlMatch match = new ElementMatch("*", MatchMode.EndElement);
		    XmlReader reader = GetReader("<foo><bar></bar></foo>");
		    reader.MoveToContent();
		    reader.Read();

		    Assert.IsFalse(match.Matches(reader, null));

		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));

		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));
		}
示例#32
0
		public void MatchCanReceiveNullResolver()
		{
			XmlMatch match = new ElementMatch("foo");
			XmlReader reader = GetReader("<foo/>");

			match.Matches(reader, null);
		}
示例#33
0
		public void ThrowsIfPrefixUnresolvable()
		{
			XmlMatch match = new ElementMatch("foo", "bar");
			XmlReader reader = GetReader("<bar/>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);

			match.Matches(reader, ns);
		}
示例#34
0
		public void ElementMatchOptionMatchesOnlyElement()
		{
			XmlMatch match = new ElementMatch("id");
			XmlReader reader = GetReader("<bar id='23'>hello</bar>");
			reader.MoveToContent();
			reader.MoveToFirstAttribute();

			Assert.IsFalse(match.Matches(reader, null));

			match = new ElementMatch("hello");
			reader.MoveToElement();
			reader.Read();

			Assert.AreEqual(XmlNodeType.Text, reader.NodeType);

			Assert.IsFalse(match.Matches(reader, null));
		}
示例#35
0
		public void BothWildcardMatchesAnyEndElementAndNamespace()
		{
		    XmlMatch match = new ElementMatch("*", "*", MatchMode.EndElement);
		    XmlReader reader = GetReader("<foo><bar xmlns='xml-mvp'></bar></foo>");
		    reader.MoveToContent();
		    reader.Read();
		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));

		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));
		}
示例#36
0
		public void ThrowsIfWildcardNameCannotResolvePrefix()
		{
			XmlMatch match = new ElementMatch("x", "*");
			XmlReader reader = GetReader("<x:foo xmlns:x='xml-mvp'><x:bar/></x:foo>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);
			ns.AddNamespace("y", "xml-mvp");

			match.Matches(reader, ns);
		}
示例#37
0
		public void EndElementMatchOptionMatchesEndElement()
		{
			XmlMatch match = new ElementMatch("bar", MatchMode.EndElement);
			XmlReader reader = GetReader("<bar></bar>");
			reader.MoveToContent();
			reader.Read();

			Assert.IsTrue(match.Matches(reader, null));
		}
示例#38
0
		public void MatchesNameWithPrefixDocumentWithoutPrefixButNamespace()
		{
			XmlMatch match = new ElementMatch("foo", "bar");
			XmlReader reader = GetReader("<bar xmlns='xml-mvp'/>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);
			ns.AddNamespace("foo", "xml-mvp");

			Assert.IsTrue(match.Matches(reader, ns));
		}
示例#39
0
		public void DoesNotMatchSameLocalNameButWrongNamespace2()
		{
			XmlMatch match = new ElementMatch("foo", "bar");
			XmlReader reader = GetReader("<bar/>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);
			ns.AddNamespace("foo", "xml-mvp");

			Assert.IsFalse(match.Matches(reader, ns));
		}
示例#40
0
		public void ElementMatchOptionDoesNotMatchEndElement()
		{
			XmlMatch match = new ElementMatch("bar");
			XmlReader reader = GetReader("<bar></bar>");
			reader.MoveToContent();
			reader.Read();

			Assert.IsFalse(match.Matches(reader, null));
		}
示例#41
0
		public void DoesNotMatchWrongLocalName()
		{
			XmlMatch match = new ElementMatch("foo");
			XmlReader reader = GetReader("<root><foo/></root>");
			reader.MoveToContent();

			Assert.IsFalse(match.Matches(reader, null));

			match = new ElementMatch("foo", MatchMode.EndElement);
			reader.Read();
			Assert.IsFalse(match.Matches(reader, null));
			reader.Read();
			Assert.IsTrue(match.Matches(reader, null));
			reader.Read();
			Assert.IsFalse(match.Matches(reader, null));
		}
示例#42
0
		public void WildcardNamespaceMatchesEndElementsInAnyNamespace()
		{
		    XmlMatch match = new ElementMatch("*", "foo", MatchMode.EndElement);
		    XmlReader reader = GetReader("<foo><foo xmlns='mvp-xml'></foo></foo>");
		    reader.MoveToContent();
		    reader.Read();
		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));

		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));
		}
示例#43
0
		public void MatchesLocalNameWithoutPrefix()
		{
			XmlMatch match = new ElementMatch("foo");
			XmlReader reader = GetReader("<foo></foo>");
			reader.MoveToContent();

			Assert.IsTrue(match.Matches(reader, null));

			reader.Read();
			match = new ElementMatch("foo", MatchMode.EndElement);

			Assert.IsTrue(match.Matches(reader, null));
		}
示例#44
0
		public void WildcardNameDoesNotMatchWrongEndElementNamespace()
		{
		    XmlMatch match = new ElementMatch("*", MatchMode.EndElement);
		    XmlReader reader = GetReader("<foo xmlns='mvp-xml'><bar xmlns=''></bar></foo>");
		    reader.MoveToContent();
		    reader.Read();
			
		    Assert.IsFalse(match.Matches(reader, null));
			
		    reader.Read();

		    Assert.IsTrue(match.Matches(reader, null));

		    reader.Read();

		    Assert.IsFalse(match.Matches(reader, null));
		}
示例#45
0
		public void WildcardNameMatchesAnyElementWithPrefix()
		{
			XmlMatch match = new ElementMatch("x", "*");
			XmlReader reader = GetReader("<x:foo xmlns:x='xml-mvp'><x:bar/></x:foo>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);
			ns.AddNamespace("x", "xml-mvp");

			Assert.IsTrue(match.Matches(reader, ns));

			reader.Read();

			Assert.IsTrue(match.Matches(reader, ns));
		}
示例#46
0
		public void CanResolveToEmptyNamespace()
		{
			XmlMatch match = new ElementMatch("foo", "bar");
			XmlReader reader = GetReader("<bar/>");
			reader.MoveToContent();

			XmlNamespaceManager ns = new XmlNamespaceManager(reader.NameTable);
			ns.AddNamespace("foo", String.Empty);

			Assert.IsTrue(match.Matches(reader, ns));
		}