//
// System.Xml.Serialization.SoapSchemaExporterTests
//
// Author:
// Gert Driesen (drieseng@users.sourceforge.net)
//
// (C) 2005 Novell
//
#if !MOBILE
using System;
using System.Collections;
using System.Globalization;
using System.IO;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using NUnit.Framework;
using MonoTests.System.Xml.TestClasses;
namespace MonoTests.System.XmlSerialization
{
[TestFixture]
public class SoapSchemaExporterTests
{
private XmlSchemas Export (Type type)
{
return Export (type, string.Empty);
}
private XmlSchemas Export (Type type, string defaultNamespace)
{
SoapReflectionImporter ri = new SoapReflectionImporter (defaultNamespace);
XmlSchemas schemas = new XmlSchemas ();
SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
XmlTypeMapping tm = ri.ImportTypeMapping (type);
sx.ExportTypeMapping (tm);
return schemas;
}
private XmlSchemas Export (Type type, SoapAttributeOverrides overrides)
{
return Export (type, overrides, string.Empty);
}
private XmlSchemas Export (Type type, SoapAttributeOverrides overrides, string defaultNamespace)
{
SoapReflectionImporter ri = new SoapReflectionImporter (overrides, defaultNamespace);
XmlSchemas schemas = new XmlSchemas ();
SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
XmlTypeMapping tm = ri.ImportTypeMapping (type);
sx.ExportTypeMapping (tm);
return schemas;
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportStruct ()
{
XmlSchemas schemas = Export (typeof (TimeSpan), "NSTimeSpan");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
schemas = Export (typeof (TimeSpan));
Assert.AreEqual (1, schemas.Count, "#3");
sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#4");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_SimpleClass ()
{
SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
SoapAttributes attr = new SoapAttributes ();
SoapElementAttribute element = new SoapElementAttribute ();
element.ElementName = "saying";
element.IsNullable = true;
attr.SoapElement = element;
overrides.Add (typeof (SimpleClass), "something", attr);
XmlSchemas schemas = Export (typeof (SimpleClass), overrides, "NSSimpleClass");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_StringCollection ()
{
XmlSchemas schemas = Export (typeof (StringCollection), "NSStringCollection");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_StringCollectionContainer ()
{
XmlSchemas schemas = Export (typeof (StringCollectionContainer), "NSStringCollectionContainer");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_ArrayContainer ()
{
XmlSchemas schemas = Export (typeof (ArrayContainer), "NSArrayContainer");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_ClassArrayContainer ()
{
XmlSchemas schemas = Export (typeof (ClassArrayContainer), "NSClassArrayContainer");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_SimpleClassWithXmlAttributes ()
{
XmlSchemas schemas = Export (typeof (SimpleClassWithXmlAttributes), "NSSimpleClassWithXmlAttributes");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_Field ()
{
XmlSchemas schemas = Export (typeof (Field), "NSField");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_MyList ()
{
XmlSchemas schemas = Export (typeof (MyList), "NSMyList");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_Container ()
{
XmlSchemas schemas = Export (typeof (Container), "NSContainer");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_Container2 ()
{
XmlSchemas schemas = Export (typeof (Container2), "NSContainer2");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ExportClass_MyElem ()
{
Export (typeof (MyElem), "NSMyElem");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlCDataSection may not be serialized with SOAP-encoded messages.
public void ExportClass_CDataContainer ()
{
Export (typeof (CDataContainer), "NSCDataContainer");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
[ExpectedException (typeof (NotSupportedException))] // The type System.Xml.XmlCDataSection may not be serialized with SOAP-encoded messages.
public void ExportClass_NodeContainer ()
{
Export (typeof (NodeContainer), "NSNodeContainer");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_Choices ()
{
XmlSchemas schemas = Export (typeof (Choices), "NSChoices");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_WrongChoices ()
{
XmlSchemas schemas = Export (typeof (WrongChoices), "NSWrongChoices");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_TestSpace ()
{
XmlSchemas schemas = Export (typeof (TestSpace), "NSTestSpace");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_ReadOnlyProperties ()
{
XmlSchemas schemas = Export (typeof (ReadOnlyProperties), "NSReadOnlyProperties");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_ListDefaults ()
{
XmlSchemas schemas = Export (typeof (ListDefaults), "NSListDefaults");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_ClsPerson ()
{
XmlSchemas schemas = Export (typeof (clsPerson), "NSClsPerson");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_ArrayClass ()
{
XmlSchemas schemas = Export (typeof (ArrayClass), "NSArrayClass");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#4");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_StructContainer ()
{
XmlSchemas schemas = Export (typeof (StructContainer), "NSStructContainer");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportClass_SimpleClass_Array ()
{
SoapAttributeOverrides overrides = new SoapAttributeOverrides ();
SoapAttributes attr = new SoapAttributes ();
SoapElementAttribute element = new SoapElementAttribute ();
element.ElementName = "saying";
element.IsNullable = true;
attr.SoapElement = element;
overrides.Add (typeof (SimpleClass), "something", attr);
SoapReflectionImporter ri = new SoapReflectionImporter (overrides, "NSSimpleClassArray");
XmlSchemas schemas = new XmlSchemas ();
SoapSchemaExporter sx = new SoapSchemaExporter (schemas);
XmlTypeMapping tm = ri.ImportTypeMapping (typeof (SimpleClass[]));
sx.ExportTypeMapping (tm);
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportEnum ()
{
XmlSchemas schemas = Export (typeof (EnumDefaultValue), "NSEnumDefaultValue");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
schemas = Export (typeof (EnumDefaultValueNF), "NSEnumDefaultValueNF");
Assert.AreEqual (1, schemas.Count, "#3");
sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#4");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportXsdPrimitive ()
{
ArrayList types = new ArrayList ();
types.Add (new TypeDescription (typeof (object), true, "anyType", "Object"));
types.Add (new TypeDescription (typeof (byte), true, "unsignedByte", "Byte"));
types.Add (new TypeDescription (typeof (sbyte), true, "byte", "Byte"));
types.Add (new TypeDescription (typeof (bool), true, "boolean", "Boolean"));
types.Add (new TypeDescription (typeof (short), true, "short", "Short"));
types.Add (new TypeDescription (typeof (int), true, "int", "Int"));
types.Add (new TypeDescription (typeof (long), true, "long", "Long"));
types.Add (new TypeDescription (typeof (float), true, "float", "Float"));
types.Add (new TypeDescription (typeof (double), true, "double", "Double"));
types.Add (new TypeDescription (typeof (decimal), true, "decimal", "Decimal"));
types.Add (new TypeDescription (typeof (ushort), true, "unsignedShort", "UnsignedShort"));
types.Add (new TypeDescription (typeof (uint), true, "unsignedInt", "UnsignedInt"));
types.Add (new TypeDescription (typeof (ulong), true, "unsignedLong", "UnsignedLong"));
types.Add (new TypeDescription (typeof (DateTime), true, "dateTime", "DateTime"));
types.Add (new TypeDescription (typeof (XmlQualifiedName), true, "QName", "QName", true));
types.Add (new TypeDescription (typeof (string), true, "string", "String", true));
foreach (TypeDescription typeDesc in types) {
XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
Assert.AreEqual (0, schemas.Count, typeDesc.Type.FullName + "#1");
}
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportXsdPrimitive_ByteArray ()
{
XmlSchemas schemas = Export (typeof (byte[]), "ByteArray");
Assert.AreEqual (0, schemas.Count, "#1");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportXsdPrimitive_Arrays ()
{
ArrayList types = new ArrayList ();
types.Add (new TypeDescription (typeof (object[]), true, "anyType", "AnyType"));
types.Add (new TypeDescription (typeof (sbyte[]), true, "byte", "Byte"));
types.Add (new TypeDescription (typeof (bool[]), true, "boolean", "Boolean"));
types.Add (new TypeDescription (typeof (short[]), true, "short", "Short"));
types.Add (new TypeDescription (typeof (int[]), true, "int", "Int"));
types.Add (new TypeDescription (typeof (long[]), true, "long", "Long"));
types.Add (new TypeDescription (typeof (float[]), true, "float", "Float"));
types.Add (new TypeDescription (typeof (double[]), true, "double", "Double"));
types.Add (new TypeDescription (typeof (decimal[]), true, "decimal", "Decimal"));
types.Add (new TypeDescription (typeof (ushort[]), true, "unsignedShort", "UnsignedShort"));
types.Add (new TypeDescription (typeof (uint[]), true, "unsignedInt", "UnsignedInt"));
types.Add (new TypeDescription (typeof (ulong[]), true, "unsignedLong", "UnsignedLong"));
types.Add (new TypeDescription (typeof (DateTime[]), true, "dateTime", "DateTime"));
types.Add (new TypeDescription (typeof (XmlQualifiedName[]), true, "QName", "QName", true));
types.Add (new TypeDescription (typeof (string[]), true, "string", "String", true));
foreach (TypeDescription typeDesc in types) {
XmlSchemas schemas = Export (typeDesc.Type, typeDesc.Type.Name);
Assert.AreEqual (1, schemas.Count, typeDesc.Type.FullName + "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine, typeDesc.Type.Name, typeDesc.ArrayType, typeDesc.XmlType,
typeDesc.XsdType ? "xs" : "tns", typeDesc.IsNillable ? "nillable=\"true\" " : ""),
sw.ToString (), typeDesc.Type.FullName + "#2");
}
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportNonXsdPrimitive_Guid ()
{
XmlSchemas schemas = Export (typeof (Guid), "NSPrimGuid");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
[Test]
[Category ("NotWorking")] // mark it NotWorking until fixes have landed in svn
public void ExportNonXsdPrimitive_Char ()
{
XmlSchemas schemas = Export (typeof (Char), "NSPrimChar");
Assert.AreEqual (1, schemas.Count, "#1");
StringWriter sw = new StringWriter ();
schemas[0].Write (sw);
Assert.AreEqual (string.Format (CultureInfo.InvariantCulture,
"{0}" +
"{0}" +
" {0}" +
" {0}" +
" {0}" +
"", Environment.NewLine), sw.ToString (), "#2");
}
public class Employee : IXmlSerializable
{
private string _firstName;
private string _lastName;
private string _address;
public XmlSchema GetSchema ()
{
return null;
}
public void WriteXml (XmlWriter writer)
{
writer.WriteStartElement ("employee", "urn:devx-com");
writer.WriteAttributeString ("firstName", _firstName);
writer.WriteAttributeString ("lastName", _lastName);
writer.WriteAttributeString ("address", _address);
writer.WriteEndElement ();
}
public void ReadXml (XmlReader reader)
{
XmlNodeType type = reader.MoveToContent ();
if (type == XmlNodeType.Element && reader.LocalName == "employee") {
_firstName = reader["firstName"];
_lastName = reader["lastName"];
_address = reader["address"];
}
}
}
public class StructContainer
{
public EnumDefaultValue Value;
}
private class TypeDescription
{
public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType)
: this (type, xsdType, xmlType, arrayType, false)
{
}
public TypeDescription (Type type, bool xsdType, string xmlType, string arrayType, bool isNillable)
{
_type = type;
_xsdType = xsdType;
_xmlType = xmlType;
_arrayType = arrayType;
_isNillable = isNillable;
}
public Type Type
{
get { return _type; }
}
public string XmlType
{
get { return _xmlType; }
}
public string ArrayType
{
get { return _arrayType; }
}
public bool XsdType
{
get { return _xsdType; }
}
public bool IsNillable
{
get { return _isNillable; }
}
private Type _type;
private bool _xsdType;
private string _xmlType;
private string _arrayType;
private bool _isNillable;
}
}
}
#endif