mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 03:51:19 -10:00
* XmlDocumentTests.cs, XmlAttributeCollectionTests.cs XmlElementTests.cs, XmlCharacterDataTests.cs : Marked NotDotNet for some tests broken under 2.0 (MS bugs). Marked Ignore for some tests which originally does not make sense. Changed types in ExpectedException for some tests under 2.0. svn path=/trunk/mcs/; revision=54345
209 lines
4.5 KiB
C#
209 lines
4.5 KiB
C#
//
|
|
// System.Xml.XmlTextWriterTests
|
|
//
|
|
// Author: Kral Ferch <[email protected]>
|
|
// Author: Martin Willemoes Hansen <[email protected]>
|
|
//
|
|
// (C) 2002 Kral Ferch
|
|
// (C) 2003 Martin Willemoes Hansen
|
|
//
|
|
|
|
using System;
|
|
using System.Xml;
|
|
|
|
using NUnit.Framework;
|
|
|
|
namespace MonoTests.System.Xml
|
|
{
|
|
[TestFixture]
|
|
public class XmlCharacterDataTests : Assertion
|
|
{
|
|
XmlDocument document;
|
|
XmlComment comment;
|
|
bool changed;
|
|
bool changing;
|
|
|
|
[SetUp]
|
|
public void GetReady ()
|
|
{
|
|
document = new XmlDocument ();
|
|
document.NodeChanged += new XmlNodeChangedEventHandler (this.EventNodeChanged);
|
|
document.NodeChanging += new XmlNodeChangedEventHandler (this.EventNodeChanging);
|
|
comment = document.CreateComment ("foo");
|
|
}
|
|
|
|
private void EventNodeChanged(Object sender, XmlNodeChangedEventArgs e)
|
|
{
|
|
changed = true;
|
|
}
|
|
|
|
private void EventNodeChanging (Object sender, XmlNodeChangedEventArgs e)
|
|
{
|
|
changing = true;
|
|
}
|
|
|
|
[Test]
|
|
public void AppendData ()
|
|
{
|
|
changed = false;
|
|
changing = false;
|
|
comment.AppendData ("bar");
|
|
Assert (changed);
|
|
Assert (changing);
|
|
AssertEquals ("foobar", comment.Data);
|
|
|
|
comment.Value = "foo";
|
|
comment.AppendData (null);
|
|
AssertEquals ("foo", comment.Data);
|
|
}
|
|
|
|
[Test]
|
|
public void DeleteData ()
|
|
{
|
|
comment.Value = "bar";
|
|
changed = false;
|
|
changing = false;
|
|
comment.DeleteData (1, 1);
|
|
Assert (changed);
|
|
Assert (changing);
|
|
AssertEquals ("br", comment.Data);
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.DeleteData(-1, 1);
|
|
Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
|
|
}
|
|
catch (ArgumentOutOfRangeException) {}
|
|
|
|
comment.Value = "foo";
|
|
comment.DeleteData(1, 5);
|
|
AssertEquals("f", comment.Data);
|
|
|
|
comment.Value = "foo";
|
|
comment.DeleteData(3, 10);
|
|
AssertEquals("foo", comment.Data);
|
|
}
|
|
|
|
[Test]
|
|
#if NET_2_0
|
|
[Category ("NotDotNet")] // enbug in 2.0
|
|
#endif
|
|
public void InsertData ()
|
|
{
|
|
comment.Value = "foobaz";
|
|
changed = false;
|
|
changing = false;
|
|
comment.InsertData (3, "bar");
|
|
Assert (changed);
|
|
Assert (changing);
|
|
AssertEquals ("foobarbaz", comment.Data);
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.InsertData (-1, "bar");
|
|
Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
|
|
}
|
|
catch (ArgumentOutOfRangeException) {}
|
|
|
|
comment.Value = "foo";
|
|
comment.InsertData (3, "bar");
|
|
AssertEquals ("foobar", comment.Data);
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.InsertData (4, "bar");
|
|
Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
|
|
}
|
|
catch (ArgumentOutOfRangeException) {}
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.InsertData (1, null);
|
|
Fail ("Expected an ArgumentNullException to be thrown.");
|
|
}
|
|
catch (ArgumentNullException) {}
|
|
}
|
|
|
|
[Test]
|
|
#if NET_2_0
|
|
[Category ("NotDotNet")] // enbug in 2.0
|
|
#endif
|
|
public void ReplaceData ()
|
|
{
|
|
changed = false;
|
|
changing = false;
|
|
comment.ReplaceData (0, 3, "bar");
|
|
Assert (changed);
|
|
Assert (changing);
|
|
AssertEquals ("bar", comment.Data);
|
|
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (2, 3, "bar");
|
|
AssertEquals ("fobar", comment.Data);
|
|
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (3, 3, "bar");
|
|
AssertEquals ("foobar", comment.Data);
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (4, 3, "bar");
|
|
Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
|
|
}
|
|
catch (ArgumentOutOfRangeException) {}
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (-1, 3, "bar");
|
|
Fail ("Expected an ArgumentOutOfRangeException to be thrown.");
|
|
}
|
|
catch (ArgumentOutOfRangeException) {}
|
|
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (0, 2, "bar");
|
|
AssertEquals ("baro", comment.Data);
|
|
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (0, 5, "bar");
|
|
AssertEquals ("bar", comment.Data);
|
|
|
|
try
|
|
{
|
|
comment.Value = "foo";
|
|
comment.ReplaceData (1, 1, null);
|
|
Fail ("Expected an ArgumentNullException to be thrown.");
|
|
}
|
|
catch (ArgumentNullException) {}
|
|
}
|
|
|
|
[Test]
|
|
public void Substring ()
|
|
{
|
|
comment.Value = "test string";
|
|
AssertEquals ("test string", comment.Substring (0, 50));
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (ArgumentOutOfRangeException))]
|
|
public void SubstringStartOutOfRange ()
|
|
{
|
|
comment.Value = "test string";
|
|
comment.Substring (-5, 10);
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (ArgumentOutOfRangeException))]
|
|
public void SubstringCountOutOfRange ()
|
|
{
|
|
comment.Value = "test string";
|
|
comment.Substring (10, -5);
|
|
}
|
|
}
|
|
}
|