diff options
author | Gert Driesen <drieseng@users.sourceforge.net> | 2006-01-05 23:16:41 +0300 |
---|---|---|
committer | Gert Driesen <drieseng@users.sourceforge.net> | 2006-01-05 23:16:41 +0300 |
commit | cd7644c9972bca5348cdabe1fc1870d65419737b (patch) | |
tree | 2437870b04fb461a9554ff5dba60ff1f0280ab81 /mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs | |
parent | 2cde67007d2379f90ec0aa07ce7a0512ad0bffb6 (diff) |
* XmlTextWriter.cs: Modified WriteWhitespace to throw ArgumentException
if value is null or zero-length string. Modified WriteNmToken to throw
ArgumentException if name is null or zero-length string. Cosmetic
change to WriteStringInternal.
* XmlElement.cs: In 2.0 profile, do not throw ArgumentNullException
if new value for Prefix is null.
* XmlElementTests.cs: Improved tests for setting prefix to null
or zero-length string. On 2.0 profile, setting prefix to null should
not result in ArgumentNullException.
* XmlTextWriterTests.cs: Enabled WriteNmToken tests and
WriteWhitespace tests for null or zero-length value.
svn path=/trunk/mcs/; revision=55115
Diffstat (limited to 'mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs')
-rw-r--r-- | mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs b/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs index 89af454522c..bce3a735ef9 100644 --- a/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs +++ b/mcs/class/System.XML/Test/System.Xml/XmlElementTests.cs @@ -561,20 +561,48 @@ namespace MonoTests.System.Xml } [Test] +#if ONLY_1_1 [ExpectedException (typeof (ArgumentNullException))] +#endif public void SetNullPrefix () { XmlDocument doc = new XmlDocument (); doc.LoadXml ("<root/>"); doc.DocumentElement.Prefix = null; + +#if NET_2_0 + AssertEquals ("#1", string.Empty, doc.DocumentElement.Prefix); + AssertClearPrefix ((string) null); +#endif } [Test] public void SetEmptyStringPrefix () { XmlDocument doc = new XmlDocument (); - doc.LoadXml ("<root/>"); + doc.LoadXml ("<root />"); doc.DocumentElement.Prefix = String.Empty; + AssertEquals ("#1", string.Empty, doc.DocumentElement.Prefix); + + AssertClearPrefix (string.Empty); + + } + + private void AssertClearPrefix (string newPrefix) + { + XmlDocument doc = new XmlDocument (); + doc.LoadXml ("<x:root xmlns:x=\"http://somenamespace.com\" />"); + AssertEquals ("#Clear1", "<x:root xmlns:x=\"http://somenamespace.com\" />", + doc.OuterXml); + AssertEquals ("#Clear2", "<x:root xmlns:x=\"http://somenamespace.com\" />", + doc.DocumentElement.OuterXml); + AssertEquals ("#Clear3", "x", doc.DocumentElement.Prefix); + doc.DocumentElement.Prefix = newPrefix; + AssertEquals ("#Clear4", "<root xmlns:x=\"http://somenamespace.com\" xmlns=\"http://somenamespace.com\" />", + doc.OuterXml); + AssertEquals ("#Clear5", "<root xmlns:x=\"http://somenamespace.com\" xmlns=\"http://somenamespace.com\" />", + doc.DocumentElement.OuterXml); + AssertEquals ("#Clear6", string.Empty, doc.DocumentElement.Prefix); } } } |