예제 #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));
		}