Exemplo n.º 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));
		}
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 7
0
        public void MatchCanReceiveNullResolver()
        {
            XmlMatch  match  = new ElementMatch("foo");
            XmlReader reader = GetReader("<foo/>");

            match.Matches(reader, null);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
		}
Exemplo n.º 11
0
		public void ShouldMatchElementForRootToo()
		{
			XmlReader reader = GetReader("<root/>");
			ElementMatch match = new ElementMatch("root", MatchMode.StartElement);

			reader.MoveToContent();

			Assert.IsTrue(match.Matches(reader, null));
		}
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 14
0
        public void ShouldMatchElementForRootToo()
        {
            XmlReader    reader = GetReader("<root/>");
            ElementMatch match  = new ElementMatch("root", MatchMode.StartElement);

            reader.MoveToContent();

            Assert.IsTrue(match.Matches(reader, null));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
		}
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
		}
Exemplo n.º 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);
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 32
0
		public void MatchCanReceiveNullResolver()
		{
			XmlMatch match = new ElementMatch("foo");
			XmlReader reader = GetReader("<foo/>");

			match.Matches(reader, null);
		}
Exemplo n.º 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);
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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);
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}
Exemplo n.º 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));
		}