// // ServiceDescriptionReflectorTest.cs // // Author: // Gert Driesen // Atsushi Enomoto // // Copyright (C) 2007 Gert Driesen // Copyright (C) 2006 Novell, Inc. // using NUnit.Framework; using System; using System.Globalization; using System.IO; using System.Web.Services; using System.Web.Services.Description; using System.Xml.Schema; using System.Xml.Serialization; namespace MonoTests.System.Web.Services.Description { [TestFixture] public class ServiceDescriptionReflectorTest { #if NET_2_0 [Test] public void ReflectNullableInt () { ServiceDescriptionReflector r = new ServiceDescriptionReflector (); r.Reflect (typeof (NullableContainer), null); ServiceDescription sd = r.ServiceDescriptions [0]; XmlSchema xs = sd.Types.Schemas [0]; XmlSchemaElement el = null; foreach (XmlSchemaElement e in xs.Items) { if (e.Name != "GetNullResponse") continue; el = e; break; } XmlSchemaComplexType ct = el.SchemaType as XmlSchemaComplexType; XmlSchemaSequence s = ct.Particle as XmlSchemaSequence; XmlSchemaElement e2 = s.Items [0] as XmlSchemaElement; Assert.IsTrue (e2.IsNillable); } #endif [Test] [Category ("NotWorking")] public void IncludeTest () { ServiceDescriptionReflector reflector = new ServiceDescriptionReflector (); reflector.Reflect (typeof (IncludeTestServices), "http://localhost/IncludeTestServices.asmx"); Assert.AreEqual (0, reflector.Schemas.Count, "#1"); Assert.AreEqual (1, reflector.ServiceDescriptions.Count, "#2"); ServiceDescription sd = reflector.ServiceDescriptions[0]; Assert.IsNull (sd.Name, "#3"); Assert.AreEqual (1, sd.Types.Schemas.Count, "#4"); StringWriter sw = new StringWriter (); sd.Write (sw); Assert.AreEqual (string.Format(CultureInfo.InvariantCulture, "{0}" + #if NET_2_0 "{0}" + #else "{0}" + #endif " {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}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + #if NET_2_0 " {0}" + #else " {0}" + #endif " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + #if NET_2_0 " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + " {0}" + #endif " {0}" + #if ONLY_1_1 " {0}" + #endif " {0}" + " {0}" + " {0}" + #if NET_2_0 " {0}" + " {0}" + " {0}" + #endif " {0}" + "", Environment.NewLine), sw.ToString (), "#5"); } public class IncludeTestServices : WebService { [WebMethod ()] [return: XmlElement ("MyTime", DataType = "time")] public DateTime EchoString ([XmlElement (DataType = "string")] string strval) { return DateTime.Now; } [WebMethod ()] [XmlInclude (typeof (Car))] public Vehicle Vehicle (string licenseNumber) { if (licenseNumber == "0") { Vehicle v = new Car (); v.licenseNumber = licenseNumber; return v; } else { return null; } } } [XmlRoot ("NewVehicle")] public abstract class Vehicle { public string licenseNumber; public DateTime make; public TimeSpan age; } public class Car : Vehicle { } public class NullableContainer { [WebMethod (Description="Test nullables")] public int? GetNull () { return null; } } } }