using System;
using System.Collections;
+using DefaultValueAttribute = System.ComponentModel.DefaultValueAttribute;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestIntTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (int));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestStringTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (string));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestByteTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (byte));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestBoolTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (bool));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestShortTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (short));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestUnsignedShortTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (ushort));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestUIntTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (uint));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestLongTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (long));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestULongTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (ulong));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestFloatTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (float));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestDoubleTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (double));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestDateTimeTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (DateTime));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestGuidTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (Guid));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestDecimalTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (decimal));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestXmlQualifiedNameTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (XmlQualifiedName));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestSByteTypeMapping ()
{
XmlTypeMapping tm = Map (typeof (sbyte));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TestCharTypeMapping()
{
XmlTypeMapping tm = Map (typeof (char));
Assert.AreEqual ("MonoTests.System.Xml.TestClasses.SimpleClass[][]", tm.TypeFullName, "#B4");
}
+ [Test]
+#if ONLY_1_1
+ [Category ("NotDotNet")] // wrong error message is reported in .NET 1.1
+#endif
+ public void TypeMapping_Attribute_ComplexType ()
+ {
+ SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Names")[0]);
+ attrs.SoapAttribute = new SoapAttributeAttribute (); // SoapAttribute cannot be used to encode complex types
+ SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
+ overrides.Add (typeof (Field_Encoded), "Names", attrs);
+
+ try {
+ Map (typeof (Field_Encoded), overrides);
+ Assert.Fail ("#A1");
+ } catch (InvalidOperationException ex) {
+ // Cannot serialize member 'Names' of type System.String[].
+ // SoapAttribute cannot be used to encode complex types.
+ Assert.IsNotNull (ex.Message, "#A2");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (string[]).FullName) != -1, "#A3");
+ Assert.IsTrue (ex.Message.IndexOf ("SoapAttribute") != -1, "#A4");
+ Assert.IsNull (ex.InnerException, "#A5");
+ }
+ }
+
+ [Test]
+ public void TypeMapping_Field ()
+ {
+ XmlTypeMapping tm = Map (typeof (Field));
+ Assert.AreEqual ("Field", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("Field", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ public void TypeMapping_Field_DefaultNamespace ()
+ {
+ XmlTypeMapping tm = Map (typeof (Field), SomeNamespace);
+ Assert.AreEqual ("Field", tm.ElementName, "#1");
+ Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
+ Assert.AreEqual ("Field", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ public void TypeMapping_Field_Encoded ()
+ {
+ XmlTypeMapping tm = Map (typeof (Field_Encoded));
+ Assert.AreEqual ("field", tm.ElementName, "#1");
+ Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
+ Assert.AreEqual ("Field_Encoded", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field_Encoded", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ public void TypeMapping_Field_Encoded_DefaultNamespace ()
+ {
+ XmlTypeMapping tm = Map (typeof (Field_Encoded), AnotherNamespace);
+ Assert.AreEqual ("field", tm.ElementName, "#1");
+ Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
+ Assert.AreEqual ("Field_Encoded", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.Field_Encoded", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ public void TypeMapping_FlagEnum ()
+ {
+ XmlTypeMapping tm = Map (typeof (FlagEnum));
+ Assert.AreEqual ("FlagEnum", tm.ElementName, "#1");
+ Assert.AreEqual (string.Empty, tm.Namespace, "#2");
+ Assert.AreEqual ("FlagEnum", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.FlagEnum", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ public void TypeMapping_FlagEnum_DefaultNamespace ()
+ {
+ XmlTypeMapping tm = Map (typeof (FlagEnum), SomeNamespace);
+ Assert.AreEqual ("FlagEnum", tm.ElementName, "#1");
+ Assert.AreEqual (SomeNamespace, tm.Namespace, "#2");
+ Assert.AreEqual ("FlagEnum", tm.TypeName, "#3");
+ Assert.AreEqual ("MonoTests.System.Xml.TestClasses.FlagEnum", tm.TypeFullName, "#4");
+ }
+
+ [Test]
+ [ExpectedException (typeof (NotSupportedException))]
+ public void TypeMapping_IDictionary ()
+ {
+ // The type MonoTests.System.Xml.TestClasses.DictionaryWithIndexer
+ // is not supported because it implements IDictionary.
+ Map (typeof (DictionaryWithIndexer));
+ }
+
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void TypeMapping_IEnumerable_SimpleClass ()
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (InvalidOperationException))]
public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod ()
{
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (InvalidOperationException))]
public void TypeMapping_IEnumerable_Object_NoMatchingAddMethod_Array ()
{
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
-/*
#if ONLY_1_1
[Category ("NotDotNet")] // results in NullReferenceException in .NET 1.1 (SP1)
#endif
- */
public void TypeMapping_IEnumerable_SimpleClass_PrivateGetEnumerator ()
{
XmlTypeMapping tm = Map (typeof (SimpleClassEnumerablePrivateGetEnumerator));
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (InvalidOperationException))]
public void TypeMapping_ICollection_Object_NoMatchingAddMethod ()
{
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (InvalidOperationException))]
public void TypeMapping_ICollection_Object_NoMatchingAddMethod_Array ()
{
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (InvalidOperationException))]
public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod ()
{
}
[Test]
- [Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (InvalidOperationException))]
public void TypeMapping_ICollection_SimpleClass_NoMatchingAddMethod_Array ()
{
Map (typeof (SimpleClassCollectionNoIntIndexer[]));
}
+ [Test]
+ public void TypeMapping_InvalidDefault ()
+ {
+ SoapAttributes attrs = new SoapAttributes (typeof (Field_Encoded).GetMember ("Modifiers")[0]);
+ attrs.SoapDefaultValue = 2; // not a defined enum value
+ SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
+ overrides.Add (typeof (Field_Encoded), "Modifiers", attrs);
+
+ try {
+ Map (typeof (Field_Encoded), overrides);
+ Assert.Fail ("#A1");
+ } catch (InvalidOperationException ex) {
+ // Enum System.Int32 cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
+ Assert.IsNotNull (ex.Message, "#A2");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (int).FullName) != -1, "#A3");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#A4");
+ Assert.IsNull (ex.InnerException, "#A5");
+ }
+
+ attrs.SoapDefaultValue = "2"; // not of the same type as the underlying enum type (System.Int32)
+
+ try {
+ Map (typeof (Field_Encoded), overrides);
+ Assert.Fail ("#B1");
+ } catch (InvalidOperationException ex) {
+ // Enum System.String cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
+ Assert.IsNotNull (ex.Message, "#B2");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (string).FullName) != -1, "#B3");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#B4");
+ Assert.IsNull (ex.InnerException, "#B5");
+ }
+
+ attrs.SoapDefaultValue = EnumDefaultValueNF.e2; // other enum type
+
+ try {
+ Map (typeof (Field_Encoded), overrides);
+ Assert.Fail ("#C1");
+ } catch (InvalidOperationException ex) {
+ // Enum MonoTests.System.Xml.TestClasses.EnumDefaultValueNF cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
+ Assert.IsNotNull (ex.Message, "#C2");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (EnumDefaultValueNF).FullName) != -1, "#C3");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#C4");
+ Assert.IsNull (ex.InnerException, "#C5");
+ }
+
+ attrs.SoapDefaultValue = (MapModifiers) 20; // non-existing enum value
+
+ try {
+ Map (typeof (Field_Encoded), overrides);
+ Assert.Fail ("#D1");
+ } catch (InvalidOperationException ex) {
+ // Value '20' cannot be converted to MonoTests.System.Xml.TestClasses.MapModifiers
+ Assert.IsNotNull (ex.Message, "#D2");
+ Assert.IsTrue (ex.Message.IndexOf ("'20'") != -1, "#D3");
+ Assert.IsTrue (ex.Message.IndexOf (typeof (MapModifiers).FullName) != -1, "#D4");
+ Assert.IsNull (ex.InnerException, "#D5");
+ }
+ }
+
[Test]
[Category ("NotWorking")]
public void TestImportMembersMapping()