Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

67 lines
1.3 KiB
C#

//
// RelaxngReaderTests.cs
//
// Authors:
// Atsushi Enomoto <ginga@kit.hi-ho.ne.jp>
//
// (C) 2003 Atsushi Enomoto
//
using System;
using System.IO;
using System.Xml;
using Commons.Xml.Relaxng;
using NUnit.Framework;
namespace MonoTests.Commons.Xml.Relaxng
{
[TestFixture]
public class RelaxngReaderTests
{
RelaxngReader reader;
[SetUp]
public void SetUp ()
{
}
private void loadGrammarFromUrl (string url)
{
reader = new RelaxngReader (new XmlTextReader (url));
}
[Test]
public void SimpleRead ()
{
loadGrammarFromUrl ("Test/XmlFiles/SimpleElementPattern1.rng");
RelaxngPattern p = reader.ReadPattern ();
Assert.AreEqual (RelaxngPatternType.Element, p.PatternType);
}
[Test]
public void CompileRelaxngGrammar ()
{
loadGrammarFromUrl ("Test/XmlFiles/relaxng.rng");
RelaxngPattern p = reader.ReadPattern ();
Assert.AreEqual (RelaxngPatternType.Grammar, p.PatternType);
p.Compile ();
}
[Test]
public void Bug347945 ()
{
string rng = @"
<element name='x' xmlns='http://relaxng.org/ns/structure/1.0'>
<interleave>
<element name='y'><text/></element>
<element name='z'><text/></element>
</interleave>
</element>";
RelaxngPattern p = RelaxngPattern.Read (new XmlTextReader (rng, XmlNodeType.Document, null));
}
}
}