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)); }
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)); }
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)); }
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)); }
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)); }
public void MatchCanReceiveNullResolver() { XmlMatch match = new ElementMatch("foo"); XmlReader reader = GetReader("<foo/>"); match.Matches(reader, null); }
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)); }
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)); }
public void ShouldMatchStartElementCloseIfNoAttributes() { XmlReader reader = GetReader("<root></root>"); ElementMatch match = new ElementMatch("root", MatchMode.StartElementClosed); reader.MoveToContent(); Assert.IsTrue(match.Matches(reader, null)); }
public void ShouldMatchElementForRootToo() { XmlReader reader = GetReader("<root/>"); ElementMatch match = new ElementMatch("root", MatchMode.StartElement); reader.MoveToContent(); Assert.IsTrue(match.Matches(reader, null)); }
public void MatchThrowsIfPrefixButNoResolver() { XmlMatch match = new ElementMatch("foo", "bar"); XmlReader reader = GetReader("<foo:bar xmlns:foo='xml-mvp'/>"); reader.MoveToContent(); match.Matches(reader, null); }
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); }
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)); }
public void ElementMatchOptionDoesNotMatchEndElement() { XmlMatch match = new ElementMatch("bar"); XmlReader reader = GetReader("<bar></bar>"); reader.MoveToContent(); reader.Read(); Assert.IsFalse(match.Matches(reader, null)); }
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)); }
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); }
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)); }
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)); }
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)); }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }