Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,57 @@
//
// CodeIdentifiersTest.cs
//
// Author:
// Atsushi Enomoto <atsushi@ximian.com>
//
// Copyright (C) 2006 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Xml.Serialization;
using NUnit.Framework;
using MonoTests.System.Xml.TestClasses;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class CodeIdentifiersTests
{
#if NET_2_0
[Test]
[ExpectedException (typeof (ArgumentException))]
public void IgnoreCase ()
{
CodeIdentifiers c = new CodeIdentifiers (false);
c.Add ("test", "x");
c.Add ("Test", "y");
Assert.IsTrue ("test" != c.AddUnique ("Test", "z"), "#1");
Assert.IsTrue (c.IsInUse ("tEsT"), "#2");
Assert.AreEqual ("camelCase", c.MakeRightCase ("CAMELCASE"), "#3");
}
#endif
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,46 @@
//
// Tests for System.Xml.Serialization.SoapAttributeAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapAttributeAttributeTests
{
[Test]
public void AttributeNameDefault ()
{
SoapAttributeAttribute attr = new SoapAttributeAttribute ();
Assert.AreEqual (string.Empty, attr.AttributeName, "#1");
attr.AttributeName = null;
Assert.AreEqual (string.Empty, attr.AttributeName, "#2");
}
[Test]
public void DataTypeDefault ()
{
SoapAttributeAttribute attr = new SoapAttributeAttribute ();
Assert.AreEqual (string.Empty, attr.DataType, "#1");
attr.DataType = null;
Assert.AreEqual (string.Empty, attr.DataType, "#2");
}
[Test]
public void NamespaceDefault ()
{
SoapAttributeAttribute attr = new SoapAttributeAttribute ();
Assert.IsNull (attr.Namespace);
}
}
}

View File

@@ -0,0 +1,65 @@
//
// System.Xml.XmlAttributesTests
//
// Author:
// Gert Driesen
//
// (C) 2006 Novell
//
using System;
using System.Xml.Serialization;
using NUnit.Framework;
using MonoTests.System.Xml.TestClasses;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapAttributesTests
{
[Test]
#if NET_2_0
// in .NET 2.0, SoapDefaultValue should be null by default, but we need
// more tests before making this change
[Category ("NotDotNet")]
#endif
public void Defaults ()
{
SoapAttributes atts = new SoapAttributes ();
Assert.IsNull (atts.SoapAttribute, "#1");
Assert.IsNotNull (atts.SoapDefaultValue, "#2");
Assert.AreEqual (DBNull.Value, atts.SoapDefaultValue, "#3");
Assert.IsNull (atts.SoapElement, "#4");
Assert.IsNull (atts.SoapEnum, "#5");
Assert.AreEqual (false, atts.SoapIgnore, "#6");
Assert.IsNull (atts.SoapType, "#7");
}
[Test]
public void SoapType ()
{
SoapAttributes atts = new SoapAttributes (typeof (TestDefault));
Assert.IsNotNull (atts.SoapType, "#1");
Assert.AreEqual ("testDefault", atts.SoapType.TypeName, "#2");
Assert.AreEqual ("urn:myNS", atts.SoapType.Namespace, "#3");
}
[Test]
public void SoapDefaultValue ()
{
SoapAttributes atts = new SoapAttributes (typeof (TestDefault).GetMember("strDefault")[0]);
Assert.IsNotNull (atts.SoapDefaultValue, "#1");
Assert.AreEqual ("Default Value", atts.SoapDefaultValue, "#2");
}
[Test]
public void SoapEnum ()
{
SoapAttributes atts = new SoapAttributes (typeof (FlagEnum_Encoded).GetMember("e1")[0]);
Assert.IsNotNull (atts.SoapEnum, "#1");
Assert.AreEqual ("one", atts.SoapEnum.Name, "#2");
}
}
}

View File

@@ -0,0 +1,46 @@
//
// Tests for System.Xml.Serialization.SoapElementAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapElementAttributeTests
{
[Test]
public void DataTypeDefault ()
{
SoapElementAttribute attr = new SoapElementAttribute ();
Assert.AreEqual (string.Empty, attr.DataType, "#1");
attr.DataType = null;
Assert.AreEqual (string.Empty, attr.DataType, "#2");
}
[Test]
public void ElementNameDefault ()
{
SoapElementAttribute attr = new SoapElementAttribute ();
Assert.AreEqual (string.Empty, attr.ElementName, "#1");
attr.ElementName = null;
Assert.AreEqual (string.Empty, attr.ElementName, "#2");
}
[Test]
public void IsNullableDefault ()
{
SoapElementAttribute attr = new SoapElementAttribute ();
Assert.AreEqual (false, attr.IsNullable);
}
}
}

View File

@@ -0,0 +1,29 @@
//
// Tests for System.Xml.Serialization.SoapEnumAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapEnumAttributeTests
{
[Test]
public void NameDefault ()
{
SoapEnumAttribute attr = new SoapEnumAttribute ();
Assert.AreEqual (string.Empty, attr.Name, "#1");
attr.Name = null;
Assert.AreEqual (string.Empty, attr.Name, "#2");
}
}
}

View File

@@ -0,0 +1,26 @@
//
// Tests for System.Xml.Serialization.SoapIncludeAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapIncludeAttributeTests
{
[Test]
public void TypeDefault ()
{
SoapIncludeAttribute attr = new SoapIncludeAttribute (null);
Assert.IsNull (attr.Type);
}
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
//
// Tests for System.Xml.Serialization.SoapSchemaMember
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml;
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapSchemaMemberTests
{
[Test]
public void MemberNameDefault ()
{
SoapSchemaMember member = new SoapSchemaMember ();
Assert.AreEqual (string.Empty, member.MemberName);
member.MemberName = null;
Assert.AreEqual (string.Empty, member.MemberName);
}
[Test]
public void MemberTypeDefault ()
{
SoapSchemaMember member = new SoapSchemaMember ();
Assert.AreEqual (XmlQualifiedName.Empty, member.MemberType);
}
}
}

View File

@@ -0,0 +1,43 @@
//
// Tests for System.Xml.Serialization.SoapTypeAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapTypeAttributeTests
{
[Test]
public void IncludeInSchemaDefault ()
{
SoapTypeAttribute attr = new SoapTypeAttribute ();
Assert.AreEqual (true, attr.IncludeInSchema);
}
[Test]
public void NamespaceDefault ()
{
SoapTypeAttribute attr = new SoapTypeAttribute ();
Assert.IsNull (attr.Namespace);
}
[Test]
public void TypeNameDefault ()
{
SoapTypeAttribute attr = new SoapTypeAttribute ();
Assert.AreEqual (string.Empty, attr.TypeName, "#1");
attr.TypeName = null;
Assert.AreEqual (string.Empty, attr.TypeName, "#2");
}
}
}

View File

@@ -0,0 +1,36 @@
//
// Tests for System.Xml.Serialization.XmlAnyElementAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class XmlAnyElementAttributeTests
{
[Test]
public void NameDefault ()
{
XmlAnyElementAttribute attr = new XmlAnyElementAttribute ();
Assert.AreEqual (string.Empty, attr.Name, "#1");
attr.Name = null;
Assert.AreEqual (string.Empty, attr.Name, "#2");
}
[Test]
public void NamespaceDefault ()
{
XmlAnyElementAttribute attr = new XmlAnyElementAttribute ();
Assert.IsNull (attr.Namespace);
}
}
}

View File

@@ -0,0 +1,51 @@
//
// Tests for System.Xml.Serialization.XmlArrayAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Schema;
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class XmlArrayAttributeTests
{
[Test]
public void ElementNameDefault ()
{
XmlArrayAttribute attr = new XmlArrayAttribute ();
Assert.AreEqual (string.Empty, attr.ElementName, "#1");
attr.ElementName = null;
Assert.AreEqual (string.Empty, attr.ElementName, "#2");
}
[Test]
public void FormDefault ()
{
XmlArrayAttribute attr = new XmlArrayAttribute ();
Assert.AreEqual (XmlSchemaForm.None, attr.Form);
}
[Test]
public void IsNullableDefault ()
{
XmlArrayAttribute attr = new XmlArrayAttribute ();
Assert.AreEqual (false, attr.IsNullable);
}
[Test]
public void NamespaceDefault ()
{
XmlArrayAttribute attr = new XmlArrayAttribute ();
Assert.IsNull (attr.Namespace);
}
}
}

View File

@@ -0,0 +1,75 @@
//
// Tests for System.Xml.Serialization.XmlArrayItemAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Schema;
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class XmlArrayItemAttributeTests
{
[Test]
public void DataTypeDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.AreEqual (string.Empty, attr.DataType, "#1");
attr.DataType = null;
Assert.AreEqual (string.Empty, attr.DataType, "#2");
}
[Test]
public void ElementNameDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.AreEqual (string.Empty, attr.ElementName, "#1");
attr.ElementName = null;
Assert.AreEqual (string.Empty, attr.ElementName, "#2");
}
[Test]
public void FormDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.AreEqual (XmlSchemaForm.None, attr.Form);
}
[Test]
public void IsNullableDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.AreEqual (false, attr.IsNullable);
}
[Test]
public void NamespaceDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.IsNull (attr.Namespace);
}
[Test]
public void NestingLevelDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.AreEqual (0, attr.NestingLevel);
}
[Test]
public void TypeDefault ()
{
XmlArrayItemAttribute attr = new XmlArrayItemAttribute ();
Assert.IsNull (attr.Type);
}
}
}

View File

@@ -0,0 +1,61 @@
//
// Tests for System.Xml.Serialization.XmlAttributeAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Schema;
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class XmlAttributeAttributeTests
{
[Test]
public void AttributeNameDefault ()
{
XmlAttributeAttribute attr = new XmlAttributeAttribute ();
Assert.AreEqual (string.Empty, attr.AttributeName, "#1");
attr.AttributeName = null;
Assert.AreEqual (string.Empty, attr.AttributeName, "#2");
}
[Test]
public void DataTypeDefault ()
{
XmlAttributeAttribute attr = new XmlAttributeAttribute ();
Assert.AreEqual (string.Empty, attr.DataType, "#1");
attr.DataType = null;
Assert.AreEqual (string.Empty, attr.DataType, "#2");
}
[Test]
public void FormDefault ()
{
XmlAttributeAttribute attr = new XmlAttributeAttribute ();
Assert.AreEqual (XmlSchemaForm.None, attr.Form);
}
[Test]
public void NamespaceDefault ()
{
XmlAttributeAttribute attr = new XmlAttributeAttribute ();
Assert.IsNull (attr.Namespace);
}
[Test]
public void TypeDefault ()
{
XmlAttributeAttribute attr = new XmlAttributeAttribute ();
Assert.IsNull (attr.Type);
}
}
}

View File

@@ -0,0 +1,133 @@
//
// System.Xml.XmlAttributesTests
//
// Author:
// Atsushi Enomoto
//
// (C) 2003 Atsushi Enomoto
//
using System;
using System.IO;
using System.Text;
using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class XmlAttributesTests
{
StringWriter sw;
XmlTextWriter xtw;
XmlSerializer xs;
private void SetUpWriter ()
{
sw = new StringWriter ();
xtw = new XmlTextWriter (sw);
xtw.QuoteChar = '\'';
xtw.Formatting = Formatting.None;
}
private string WriterText
{
get
{
string val = sw.GetStringBuilder ().ToString();
int offset = val.IndexOf ('>') + 1;
val = val.Substring (offset);
return val;
}
}
private void Serialize (object o, XmlAttributeOverrides ao)
{
SetUpWriter ();
xs = new XmlSerializer (o.GetType (), ao);
xs.Serialize (xtw, o);
}
private void Serialize (object o, XmlRootAttribute root)
{
SetUpWriter ();
xs = new XmlSerializer (o.GetType(), root);
xs.Serialize (xtw, o);
}
// Testcases.
[Test]
public void NewXmlAttributes ()
{
// seems not different from Type specified ctor().
XmlAttributes atts = new XmlAttributes ();
Assert.IsNull (atts.XmlAnyAttribute, "#1");
Assert.IsNotNull (atts.XmlAnyElements, "#2");
Assert.AreEqual (0, atts.XmlAnyElements.Count, "#3");
Assert.IsNull (atts.XmlArray, "#4");
Assert.IsNotNull (atts.XmlArrayItems, "#5");
Assert.AreEqual (0, atts.XmlArrayItems.Count, "#6");
Assert.IsNull (atts.XmlAttribute, "#7");
Assert.IsNull (atts.XmlChoiceIdentifier, "#8");
Assert.IsNotNull (atts.XmlDefaultValue, "#9");
// DBNull??
Assert.AreEqual (DBNull.Value, atts.XmlDefaultValue, "#10");
Assert.IsNotNull (atts.XmlElements, "#11");
Assert.AreEqual (0, atts.XmlElements.Count, "#12");
Assert.IsNull (atts.XmlEnum, "#13");
Assert.IsNotNull (atts.XmlIgnore, "#14");
Assert.AreEqual (TypeCode.Boolean, atts.XmlIgnore.GetTypeCode (), "#15");
Assert.AreEqual (false, atts.Xmlns, "#16");
Assert.IsNull (atts.XmlRoot, "#17");
Assert.IsNull (atts.XmlText, "#18");
Assert.IsNull (atts.XmlType, "#19");
}
[Test]
public void XmlTextAttribute ()
{
// based on default ctor.
XmlTextAttribute attr = new XmlTextAttribute ();
Assert.AreEqual ("", attr.DataType, "#1");
Assert.IsNull (attr.Type, "#2");
// based on a type.
XmlTextAttribute attr2 = new XmlTextAttribute (typeof (XmlNode));
Assert.AreEqual ("", attr.DataType, "#3");
Assert.IsNull (attr.Type, "#4");
}
[Test]
public void XmlInvalidElementAttribute ()
{
XmlAttributeOverrides ao = new XmlAttributeOverrides ();
XmlAttributes atts = new XmlAttributes ();
atts.XmlElements.Add (new XmlElementAttribute ("xInt"));
ao.Add (typeof (int), atts);
try {
Serialize (10, ao);
Assert.Fail ("Should be invalid.");
} catch (InvalidOperationException ex) {
}
}
[Test]
public void XmlIgnore ()
{
FieldInfo field = GetType ().GetField ("XmlIgnoreField");
XmlAttributes atts = new XmlAttributes (field);
Assert.AreEqual (true, atts.XmlIgnore, "#1");
Assert.AreEqual (0, atts.XmlElements.Count, "#2");
Assert.AreEqual (0, atts.XmlAnyElements.Count, "#3");
}
[XmlIgnore]
[XmlElement (IsNullable = true)]
[XmlAnyElement]
public int XmlIgnoreField;
}
}

View File

@@ -0,0 +1,29 @@
//
// Tests for System.Xml.Serialization.XmlChoiceIdentifierAttribute
//
// Author:
// Gert Driesen
//
// (C) 2005 Novell
//
using System.Xml.Serialization;
using NUnit.Framework;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class XmlChoiceIdentifierAttributeTests
{
[Test]
public void MemerNameDefault ()
{
XmlChoiceIdentifierAttribute attr = new XmlChoiceIdentifierAttribute ();
Assert.AreEqual (string.Empty, attr.MemberName, "#1");
attr.MemberName = null;
Assert.AreEqual (string.Empty, attr.MemberName, "#2");
}
}
}

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More