Skip to content

Commit

Permalink
2010-06-29 Andreia Gaita <[email protected]>
Browse files Browse the repository at this point in the history
	* XmlWriterTests.cs : added tests for bug #607967

svn path=/trunk/mcs/; revision=159643
  • Loading branch information
shana committed Jun 29, 2010
1 parent 480b30d commit 99ae6a6
Show file tree
Hide file tree
Showing 2 changed files with 161 additions and 0 deletions.
4 changes: 4 additions & 0 deletions mcs/class/System.XML/Test/System.Xml/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2010-06-29 Andreia Gaita <[email protected]>

* XmlWriterTests.cs : added tests for bug #607967.

2010-06-16 Atsushi Enomoto <[email protected]>

* XmlTextReaderTests.cs : added test for bug #608391.
Expand Down
157 changes: 157 additions & 0 deletions mcs/class/System.XML/Test/System.Xml/XmlWriterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,105 @@ public void WriteStringDifferentBehavior ()
xw.Close ();
AssertType.AreEqual ("<?xml version='1.0' encoding='utf-16'?><foo></foo>".Replace ('\'', '"'), sw.ToString ());
}

[Test]
public void CreateCLAuto () {
ConformanceLevelAuto cl = new ConformanceLevelAuto ();
XmlWriter xw = XmlWriter.Create (cl);
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateCLDoc () {
ConformanceLevelDocument cl = new ConformanceLevelDocument ();
XmlWriter xw = XmlWriter.Create (cl);
WriteState state = xw.WriteState;
}

[Test]
public void CreateCLFrag () {
ConformanceLevelFragment cl = new ConformanceLevelFragment ();
XmlWriter xw = XmlWriter.Create (cl);
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateNOCL () {
InvalidWriteState cl = new InvalidWriteState ();
XmlWriter xw = XmlWriter.Create (cl);
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateNOCLSettingsCLAuto () {
InvalidWriteState cl = new InvalidWriteState ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Auto });
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateNOCLSettingsCLDOC () {
InvalidWriteState cl = new InvalidWriteState ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Document });
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateNOCLSettingsCLFrag () {
InvalidWriteState cl = new InvalidWriteState ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Fragment });
WriteState state = xw.WriteState;
}

[Test]
public void CreateCLAutoSettingsCLDoc () {
ConformanceLevelAuto cl = new ConformanceLevelAuto ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Document });
WriteState state = xw.WriteState;
}

[Test]
public void CreateCLAutoSettingsCLFrag () {
ConformanceLevelAuto cl = new ConformanceLevelAuto ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Fragment });
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateCLDocSettingsCLAuto () {
ConformanceLevelDocument cl = new ConformanceLevelDocument ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Auto });
WriteState state = xw.WriteState;
}

[Test]
public void CreateCLDocSettingsCLFrag () {
ConformanceLevelDocument cl = new ConformanceLevelDocument ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Fragment });
WriteState state = xw.WriteState;
}

[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void CreateCLFragSettingsCLAuto () {
ConformanceLevelFragment cl = new ConformanceLevelFragment ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Auto });
WriteState state = xw.WriteState;
}

[Test]
public void CreateCLFragSettingsCLFDoc () {
ConformanceLevelFragment cl = new ConformanceLevelFragment ();
XmlWriter xw = XmlWriter.Create (cl, new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Document });
WriteState state = xw.WriteState;
}

#endif

}
Expand Down Expand Up @@ -720,4 +819,62 @@ public override XmlSpace XmlSpace {
}

}


class InvalidWriteState : XmlWriter {
public override void Close () { }
public override void Flush () { }
public override string LookupPrefix (string ns) { return null; }
public override void WriteBase64 (byte [] buffer, int index, int count) { }
public override void WriteCData (string text) { }
public override void WriteCharEntity (char ch) { }
public override void WriteChars (char [] buffer, int index, int count) { }
public override void WriteComment (string text) { }
public override void WriteDocType (string name, string pubid, string sysid, string subset) { }
public override void WriteEndAttribute () { }
public override void WriteEndDocument () { }
public override void WriteEndElement () { }
public override void WriteEntityRef (string name) { }
public override void WriteFullEndElement () { }
public override void WriteProcessingInstruction (string name, string text) {}
public override void WriteRaw (string data) {}
public override void WriteRaw (char [] buffer, int index, int count) {}
public override void WriteStartAttribute (string prefix, string localName, string ns) {}
public override void WriteStartDocument (bool standalone) {}
public override void WriteStartDocument () {}
public override void WriteStartElement (string prefix, string localName, string ns) {}
public override void WriteString (string text) {}
public override void WriteSurrogateCharEntity (char lowChar, char highChar) {}
public override void WriteWhitespace (string ws) {}

public override WriteState WriteState {
get { throw new InvalidOperationException (); }
}
}

class ConformanceLevelAuto : InvalidWriteState {
public override XmlWriterSettings Settings {
get {
return new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Auto };
}
}
}

class ConformanceLevelDocument : InvalidWriteState {
public override XmlWriterSettings Settings {
get {
return new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Document };
}
}
}

class ConformanceLevelFragment : InvalidWriteState {
public override XmlWriterSettings Settings {
get {
return new XmlWriterSettings () { ConformanceLevel = ConformanceLevel.Fragment };
}
}
}

}

0 comments on commit 99ae6a6

Please sign in to comment.