+2004-07-01 Lluis Sanchez Gual <lluis@ximian.com>
+
+ * WebServiceTest.cs, client/external/BankCodeEJBHomeTest.cs,
+ client/external/GlobalWeatherTest.cs, client/external/HPcatalogTest.cs,
+ client/external/IODCODESPOSTAUXTest.cs,
+ client/external/TemperatureServiceTest.cs,
+ client/localhost/DataServiceTest.cs,
+ client/localhost/DuplicateArrayTestTest.cs,
+ client/localhost/IncludeTestTest.cs,
+ client/localhost/TestBinding4Test.cs: Use new nunit 2.2 api.
+
+ * server/ConvDocLitWra.asmx, server/ConvDocEncWra.asmx,
+ server/ConvDocLitBar.asmx, server/ConvDocLitWra.asmx,
+ server/ConvRpc.asmx,
+
+ * wstest.cs: Added support for generating tests cases from a template.
+ Useful to test the same case in all formats and protocols.
+
+ * proxies.net.xml.gz, wsdlfiles.tar.gz: Updated.
+
+ * client/localhost/ConvDocEncBarTest.cs,
+ client/localhost/ConvDocLitBarTest.cs,
+ client/localhost/ConvDocLitWraTest.cs,
+ client/localhost/ConvRpcTest.cs,
+ client/localhost/ConvDocEncBar.asmx:
+ Improved tests. Use new nunit 2.2 api.
+
+ * Conv.cs.template: template for ConverterService client tests.
+
+ * Conv.asmx.template: template for ConverterService services.
+
+ * templates.xml: Configuration file for generating the tests.
+
2004-06-22 Lluis Sanchez Gual <lluis@ximian.com>
* proxies.net.xml.gz: Updated.
--- /dev/null
+<%@ WebService Language="c#" Codebehind="ConverterService.asmx.cs" Class="WebServiceTests.ConverterService" %>
+
+/*
+$TEMPLATE_WARNING$
+*/
+
+using System;
+using System.Collections;
+using System.Xml.Serialization;
+using System.Web.Services;
+using System.Web.Services.Protocols;
+using System.Web.Services.Description;
+
+namespace WebServiceTests
+{
+ public class UserInfo : SoapHeader
+ {
+ public int userId;
+ }
+
+ public class CurrencyInfo
+ {
+ public CurrencyInfo ()
+ {
+ }
+
+ public CurrencyInfo (string name, double rate)
+ {
+ Name = name;
+ Rate = rate;
+ }
+
+ public string Name;
+ public double Rate;
+ }
+
+ public class Simple
+ {
+ public int Dada;
+ }
+
+ [WebServiceAttribute (Namespace="urn:mono-ws-tests", Description="Web service that can make currency conversions")]
+ $SERVICE_ATTRIBUTE$
+ public class ConverterService : System.Web.Services.WebService
+ {
+ static int userCount = 0;
+ static Hashtable conversionTable;
+
+ public UserInfo userInfo;
+
+ static ConverterService ()
+ {
+ conversionTable = new Hashtable ();
+ InternalSetCurrencyRate ("USD", 1);
+ InternalSetCurrencyRate ("EUR", 0.883884 );
+ InternalSetCurrencyRate ("GBP", 0.611817 );
+ InternalSetCurrencyRate ("JPY", 118.271 );
+ InternalSetCurrencyRate ("CAD", 1.36338 );
+ InternalSetCurrencyRate ("AUD", 1.51485 );
+ InternalSetCurrencyRate ("CHF", 1.36915 );
+ InternalSetCurrencyRate ("RUR", 30.4300 );
+ InternalSetCurrencyRate ("CNY", 8.27740 );
+ InternalSetCurrencyRate ("ZAR", 7.62645 );
+ InternalSetCurrencyRate ("MXN", 10.5025 );
+ }
+
+ [WebMethod (Description="Registers the user into the system")]
+ [SoapHeaderAttribute ("userInfo", Direction = SoapHeaderDirection.Out)]
+ public void Login (string a)
+ {
+ userInfo = new UserInfo ();
+ userInfo.userId = ++userCount;
+ }
+
+ [WebMethod (Description="Converts an amount from one currency to another currency")]
+ [SoapHeaderAttribute ("userInfo")]
+ public double Convert (string sourceCurrency, string targetCurrency, double value)
+ {
+ CheckUser ();
+ double usd = (1 / GetCurrencyRate (sourceCurrency)) * value;
+ return usd * GetCurrencyRate (targetCurrency);
+ }
+
+ [WebMethod (Description="Returns a list of currency rates")]
+ [SoapHeaderAttribute ("userInfo")]
+ public CurrencyInfo[] GetCurrencyInfo ()
+ {
+ CheckUser ();
+
+ lock (conversionTable)
+ {
+ CurrencyInfo[] info = new CurrencyInfo[conversionTable.Count];
+ int n = 0;
+ foreach (CurrencyInfo cinfo in conversionTable.Values)
+ info [n++] = cinfo;
+ return info;
+ }
+ }
+
+ [WebMethod (Description="Sets the rate of a currency")]
+ [SoapHeaderAttribute ("userInfo")]
+ public void SetCurrencyRate (string currency, double rate)
+ {
+ CheckUser ();
+ InternalSetCurrencyRate (currency, rate);
+ }
+
+ static void InternalSetCurrencyRate (string currency, double rate)
+ {
+ lock (conversionTable)
+ {
+ conversionTable [currency] = new CurrencyInfo (currency, rate);
+ }
+ }
+
+ [WebMethod (Description="Returns the rate of a currency")]
+ [SoapHeaderAttribute ("userInfo")]
+ public double GetCurrencyRate ([XmlElement(DataType="Name")]string cname)
+ {
+ CheckUser ();
+ lock (conversionTable)
+ {
+ if (!conversionTable.ContainsKey (cname))
+ throw new SoapException ("Unknown currency '" + cname + "'", SoapException.ServerFaultCode);
+
+ return ((CurrencyInfo) conversionTable [cname]).Rate;
+ }
+ }
+
+ [WebMethod]
+ public void Test (Simple dada1, int dada)
+ {
+ dada = 1;
+ }
+
+ [WebMethod (MessageName="Test2")]
+ public void Test (int[] dada2, byte[] dada3, int dada)
+ {
+ dada = 1;
+ }
+
+ [WebMethod]
+ public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
+ {
+ return null;
+ }
+
+ void CheckUser ()
+ {
+ if (userInfo == null)
+ throw new SoapException ("User not logged", SoapException.ServerFaultCode);
+ }
+
+ [WebMethod]
+ [return: $XML_ELEMENT$("retret")]
+ public MyInfo GetTestInfo (string s, out string d)
+ {
+ d = "iii";
+ return new MyInfo();
+ }
+ }
+
+ public class MyInfo
+ {
+ public int a = 4;
+ public string b = "hi";
+ }
+}
--- /dev/null
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
+
+using System;
+using System.Threading;
+using NUnit.Framework;
+using System.Web.Services.Protocols;
+using System.Xml;
+using $PROXY_NAMESPACE$;
+
+namespace Localhost.$TEST_NAMESPACE$
+{
+ [TestFixture]
+ public class ConverterTest: WebServiceTest
+ {
+ [Test]
+ public void TestService ()
+ {
+ ConverterService cs = new ConverterService ();
+ cs.Login ("lluis");
+ cs.SetCurrencyRate ("EUR", 0.5);
+ Assert.AreEqual (0.5, cs.GetCurrencyRate ("EUR"), "#1");
+
+ double res = cs.Convert ("EUR","USD",6);
+ Assert.AreEqual ((int)res, (int)12, "#2");
+
+ CurrencyInfo[] infos = cs.GetCurrencyInfo ();
+ Assert.IsNotNull (infos, "infos");
+
+ foreach (CurrencyInfo info in infos)
+ {
+ double val = 0;
+ Assert.IsNotNull (info.Name, "info.Name");
+
+ switch (info.Name)
+ {
+ case "USD": val = 1; break;
+ case "EUR": val = 0.5; break;
+ case "GBP": val = 0.611817; break;
+ case "JPY": val = 118.271; break;
+ case "CAD": val = 1.36338; break;
+ case "AUD": val = 1.51485; break;
+ case "CHF": val = 1.36915; break;
+ case "RUR": val = 30.4300; break;
+ case "CNY": val = 8.27740; break;
+ case "ZAR": val = 7.62645; break;
+ case "MXN": val = 10.5025; break;
+ }
+ Assert.AreEqual (val, info.Rate, "#3 " + info.Name);
+ }
+ cs.SetCurrencyRate ("EUR", 0.9);
+ }
+
+ // Async tests
+
+ ConverterService acs;
+ bool a1;
+ bool a2;
+ bool a3;
+ AutoResetEvent eve = new AutoResetEvent (false);
+
+ [Test]
+ public void AsyncTestService ()
+ {
+ IAsyncResult ar;
+ acs = new ConverterService ();
+
+ ar = acs.BeginLogin ("lluis", null, null);
+ acs.EndLogin (ar);
+
+ acs.BeginSetCurrencyRate ("EUR", 0.5, new AsyncCallback(Callback1), null);
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#0");
+ Assert.IsTrue (a1, "#1");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#2");
+ Assert.IsTrue (a2, "#3");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#4");
+ Assert.IsTrue (a3, "#5");
+ }
+
+ void Callback1 (IAsyncResult ar)
+ {
+ acs.EndSetCurrencyRate (ar);
+ acs.BeginGetCurrencyRate ("EUR", new AsyncCallback(Callback2), null);
+ }
+
+ void Callback2 (IAsyncResult ar)
+ {
+ double res = acs.EndGetCurrencyRate (ar);
+ a1 = (res == 0.5);
+ eve.Set ();
+
+ acs.BeginConvert ("EUR","USD",6, new AsyncCallback(Callback3), null);
+ }
+
+ void Callback3 (IAsyncResult ar)
+ {
+ double res = acs.EndConvert (ar);
+ a2 = (res == 12);
+ eve.Set ();
+
+ acs.BeginGetCurrencyInfo (new AsyncCallback(Callback4),null);
+ }
+
+ void Callback4 (IAsyncResult ar)
+ {
+ CurrencyInfo[] infos = acs.EndGetCurrencyInfo (ar);
+
+ foreach (CurrencyInfo info in infos)
+ {
+ double val = 0;
+ switch (info.Name)
+ {
+ case "USD": val = 1; break;
+ case "EUR": val = 0.5; break;
+ case "GBP": val = 0.611817; break;
+ case "JPY": val = 118.271; break;
+ case "CAD": val = 1.36338; break;
+ case "AUD": val = 1.51485; break;
+ case "CHF": val = 1.36915; break;
+ case "RUR": val = 30.4300; break;
+ case "CNY": val = 8.27740; break;
+ case "ZAR": val = 7.62645; break;
+ case "MXN": val = 10.5025; break;
+ }
+ a3 = (val == info.Rate);
+ if (!a3) break;
+ }
+ eve.Set ();
+ }
+
+ [Test]
+ public void TestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ try
+ {
+ cs.SetCurrencyRate ("EUR", 0.5);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void AsyncTestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ IAsyncResult ar = cs.BeginSetCurrencyRate ("EUR", 0.5, null, null);
+ try
+ {
+ cs.EndSetCurrencyRate (ar);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void TestObjectReturn ()
+ {
+ ConverterServiceExtraTest et = new ConverterServiceExtraTest ();
+
+ // Test the Discover method.
+ et.Url = "http://localhost:8080/$ASMX_NAME$?disco";
+ et.Discover ();
+
+ string d;
+ object res = et.GetTestInfo ("hi", out d);
+
+ Assert.AreEqual ("iii", d, "t1");
+ Assert.IsNotNull (res, "t2");
+ Assert.IsTrue (res is XmlNode[], "t3");
+ XmlNode[] nods = res as XmlNode[];
+ Assert.AreEqual (5, nods.Length, "t4");
+
+ Assert.IsTrue (nods[0] is XmlAttribute, "t5");
+ XmlAttribute at = nods[0] as XmlAttribute;
+ Assert.AreEqual ("id", at.LocalName, "t6");
+
+ Assert.IsTrue (nods[1] is XmlAttribute, "t7");
+ at = nods[1] as XmlAttribute;
+ Assert.AreEqual ("type", at.LocalName, "t8");
+
+ Assert.IsTrue (nods[2] is XmlAttribute, "t9");
+ at = nods[2] as XmlAttribute;
+
+ Assert.IsTrue (nods[3] is XmlElement, "t10");
+ XmlElement el = nods[3] as XmlElement;
+ Assert.AreEqual ("a", el.Name, "t11");
+
+ Assert.IsTrue (nods[4] is XmlElement, "t12");
+ el = nods[4] as XmlElement;
+ Assert.AreEqual ("b", el.Name, "t13");
+ }
+ }
+
+ [System.Web.Services.WebServiceBindingAttribute(Name="ConverterServiceSoap", Namespace="urn:mono-ws-tests")]
+ public class ConverterServiceExtraTest : System.Web.Services.Protocols.SoapHttpClientProtocol
+ {
+ [System.Web.Services.Protocols.$METHOD_ATTRIBUTE$("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests" $METHOD_ATTRIBUTE_PARAMS$)]
+ public object GetTestInfo(string s, out string d) {
+ object[] results = this.Invoke("GetTestInfo", new object[] {s});
+ d = (string) results[1];
+ return ((object)(results[0]));
+ }
+ }
+}
mono transform.exe proxies.diff.xml ../../../../tools/corcompare/mono-api.xsl > proxies.data.html
cat header.html proxies.data.html > proxies.html
rm proxies.data.html
+
+genfiles:
+ mono wstest.exe genfiles templates.xml
using NUnit.Framework;
-public class WebServiceTest: Assertion
+public class WebServiceTest
{
}
BankCode bc = new BankCode ();
- AssertEquals ("#1", "10020000 ", bc.getCodeByName ("Berlin"));
+ Assert.AreEqual ("10020000 ", bc.getCodeByName ("Berlin"), "#1");
string s = bc.getNameByCode ("10020000 ");
- AssertEquals ("#2", "10020000 ", bc.getCodeByName (s));
+ Assert.AreEqual ("10020000 ", bc.getCodeByName (s), "#2");
}
}
}
{
StationInfo si = new StationInfo ();
string[] countries = si.listCountries ();
- AssertNotNull (countries);
- AssertEquals (215, countries.Length);
- AssertEquals ("afghanistan", countries[0]);
- AssertEquals ("spain", countries[177]);
- AssertEquals ("zimbabwe", countries[214]);
+ Assert.IsNotNull (countries);
+ Assert.AreEqual (215, countries.Length);
+ Assert.AreEqual ("afghanistan", countries[0]);
+ Assert.AreEqual ("spain", countries[177]);
+ Assert.AreEqual ("zimbabwe", countries[214]);
Station[] stations = si.searchByCountry ("spain");
- AssertNotNull (stations);
+ Assert.IsNotNull (stations);
foreach (Station sta in stations)
{
- AssertNotNull (sta);
+ Assert.IsNotNull (sta);
if (sta.icao == "LEBL")
- AssertEquals ("Barcelona / Aeropuerto", sta.name);
+ Assert.AreEqual ("Barcelona / Aeropuerto", sta.name);
}
Station[] st = si.searchByCode ("LEBL");
- AssertNotNull (st);
- AssertEquals (1, st.Length);
- AssertEquals ("Barcelona / Aeropuerto", st[0].name);
+ Assert.IsNotNull (st);
+ Assert.AreEqual (1, st.Length);
+ Assert.AreEqual ("Barcelona / Aeropuerto", st[0].name);
}
[Test]
GlobalWeather gw = new GlobalWeather ();
WeatherReport wr = gw.getWeatherReport ("LEBL");
- AssertNotNull (wr.station);
- AssertEquals ("LEBL", wr.station.icao);
- AssertEquals ("Barcelona / Aeropuerto", wr.station.name);
+ Assert.IsNotNull (wr.station);
+ Assert.AreEqual ("LEBL", wr.station.icao);
+ Assert.AreEqual ("Barcelona / Aeropuerto", wr.station.name);
}
}
}
HPcatalogService ser = new HPcatalogService ();
string[][] list = ser.getList ("F2444KG");
- AssertNotNull (list);
- AssertEquals (121, list.Length);
+ Assert.IsNotNull (list);
+ Assert.AreEqual (121, list.Length);
list = ser.getList ("D5319A");
- AssertNotNull (list);
- AssertEquals (2, list.Length);
+ Assert.IsNotNull (list);
+ Assert.AreEqual (2, list.Length);
- AssertNotNull (list[0]);
- AssertEquals ("8120-8382", list[0][0]);
- AssertEquals ("Power cord (Flint Gray) - 18 AWG, 1.8m (6.0ft) long - Has straight (F) receptacle (For 120V in the USA and Canada)", list[0][1]);
+ Assert.IsNotNull (list[0]);
+ Assert.AreEqual ("8120-8382", list[0][0]);
+ Assert.AreEqual ("Power cord (Flint Gray) - 18 AWG, 1.8m (6.0ft) long - Has straight (F) receptacle (For 120V in the USA and Canada)", list[0][1]);
- AssertNotNull (list[1]);
- AssertEquals ("5182-8895", list[1][0]);
- AssertEquals ("Heat sink support base / retention base - For Pentium II (Klamath) processor", list[1][1]);
+ Assert.IsNotNull (list[1]);
+ Assert.AreEqual ("5182-8895", list[1][0]);
+ Assert.AreEqual ("Heat sink support base / retention base - For Pentium II (Klamath) processor", list[1][1]);
}
}
Console.WriteLine ("á");
Console.WriteLine (res);
Console.WriteLine ("Pyrénées Orientales");
- AssertEquals ("Pyrénées Orientales", res);
+ Assert.AreEqual ("Pyrénées Orientales", res);
res = ser.GetZipForTown ("Perpignan",",",true);
- AssertEquals ("66000=Perpignan,66100=Perpignan", res);
+ Assert.AreEqual ("66000=Perpignan,66100=Perpignan", res);
}
}
}
TemperatureService ts = new TemperatureService ();
float temp = ts.getTemp ("95110");
- Assert (temp < 140 && temp > -60);
+ Assert.IsTrue (temp < 140 && temp > -60);
temp = ts.getTemp ("hola");
- Assert (temp == -999);
+ Assert.IsTrue (temp == -999);
}
}
}
-// Web service test for WSDL document:
-// http://localhost:8080/ConvDocEncBar.asmx?wsdl
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
using System;
+using System.Threading;
using NUnit.Framework;
+using System.Web.Services.Protocols;
+using System.Xml;
using ConvDocEncBarTests.Soap;
namespace Localhost.ConvDocEncBarTests
{
[TestFixture]
- public class ConvDocEncBarTest: WebServiceTest
+ public class ConverterTest: WebServiceTest
{
[Test]
public void TestService ()
ConverterService cs = new ConverterService ();
cs.Login ("lluis");
cs.SetCurrencyRate ("EUR", 0.5);
- AssertEquals ("#1", 0.5, cs.GetCurrencyRate ("EUR"));
+ Assert.AreEqual (0.5, cs.GetCurrencyRate ("EUR"), "#1");
double res = cs.Convert ("EUR","USD",6);
- AssertEquals ("#2", (int)res, (int)12);
+ Assert.AreEqual ((int)res, (int)12, "#2");
CurrencyInfo[] infos = cs.GetCurrencyInfo ();
- AssertNotNull ("infos", infos);
+ Assert.IsNotNull (infos, "infos");
+
foreach (CurrencyInfo info in infos)
{
double val = 0;
- AssertNotNull ("info.Name", info.Name);
+ Assert.IsNotNull (info.Name, "info.Name");
switch (info.Name)
{
case "ZAR": val = 7.62645; break;
case "MXN": val = 10.5025; break;
}
- AssertEquals ("#3 " + info.Name, val, info.Rate);
+ Assert.AreEqual (val, info.Rate, "#3 " + info.Name);
}
+ cs.SetCurrencyRate ("EUR", 0.9);
+ }
+
+ // Async tests
+
+ ConverterService acs;
+ bool a1;
+ bool a2;
+ bool a3;
+ AutoResetEvent eve = new AutoResetEvent (false);
+
+ [Test]
+ public void AsyncTestService ()
+ {
+ IAsyncResult ar;
+ acs = new ConverterService ();
+
+ ar = acs.BeginLogin ("lluis", null, null);
+ acs.EndLogin (ar);
+
+ acs.BeginSetCurrencyRate ("EUR", 0.5, new AsyncCallback(Callback1), null);
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#0");
+ Assert.IsTrue (a1, "#1");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#2");
+ Assert.IsTrue (a2, "#3");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#4");
+ Assert.IsTrue (a3, "#5");
+ }
+
+ void Callback1 (IAsyncResult ar)
+ {
+ acs.EndSetCurrencyRate (ar);
+ acs.BeginGetCurrencyRate ("EUR", new AsyncCallback(Callback2), null);
+ }
+
+ void Callback2 (IAsyncResult ar)
+ {
+ double res = acs.EndGetCurrencyRate (ar);
+ a1 = (res == 0.5);
+ eve.Set ();
+
+ acs.BeginConvert ("EUR","USD",6, new AsyncCallback(Callback3), null);
+ }
+
+ void Callback3 (IAsyncResult ar)
+ {
+ double res = acs.EndConvert (ar);
+ a2 = (res == 12);
+ eve.Set ();
+
+ acs.BeginGetCurrencyInfo (new AsyncCallback(Callback4),null);
+ }
+
+ void Callback4 (IAsyncResult ar)
+ {
+ CurrencyInfo[] infos = acs.EndGetCurrencyInfo (ar);
+
+ foreach (CurrencyInfo info in infos)
+ {
+ double val = 0;
+ switch (info.Name)
+ {
+ case "USD": val = 1; break;
+ case "EUR": val = 0.5; break;
+ case "GBP": val = 0.611817; break;
+ case "JPY": val = 118.271; break;
+ case "CAD": val = 1.36338; break;
+ case "AUD": val = 1.51485; break;
+ case "CHF": val = 1.36915; break;
+ case "RUR": val = 30.4300; break;
+ case "CNY": val = 8.27740; break;
+ case "ZAR": val = 7.62645; break;
+ case "MXN": val = 10.5025; break;
+ }
+ a3 = (val == info.Rate);
+ if (!a3) break;
+ }
+ eve.Set ();
+ }
+
+ [Test]
+ public void TestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ try
+ {
+ cs.SetCurrencyRate ("EUR", 0.5);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void AsyncTestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ IAsyncResult ar = cs.BeginSetCurrencyRate ("EUR", 0.5, null, null);
+ try
+ {
+ cs.EndSetCurrencyRate (ar);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void TestObjectReturn ()
+ {
+ ConverterServiceExtraTest et = new ConverterServiceExtraTest ();
+
+ // Test the Discover method.
+ et.Url = "http://localhost:8080/ConvDocEncBar.asmx?disco";
+ et.Discover ();
+
+ string d;
+ object res = et.GetTestInfo ("hi", out d);
+
+ Assert.AreEqual ("iii", d, "t1");
+ Assert.IsNotNull (res, "t2");
+ Assert.IsTrue (res is XmlNode[], "t3");
+ XmlNode[] nods = res as XmlNode[];
+ Assert.AreEqual (5, nods.Length, "t4");
+
+ Assert.IsTrue (nods[0] is XmlAttribute, "t5");
+ XmlAttribute at = nods[0] as XmlAttribute;
+ Assert.AreEqual ("id", at.LocalName, "t6");
+
+ Assert.IsTrue (nods[1] is XmlAttribute, "t7");
+ at = nods[1] as XmlAttribute;
+ Assert.AreEqual ("type", at.LocalName, "t8");
+
+ Assert.IsTrue (nods[2] is XmlAttribute, "t9");
+ at = nods[2] as XmlAttribute;
+
+ Assert.IsTrue (nods[3] is XmlElement, "t10");
+ XmlElement el = nods[3] as XmlElement;
+ Assert.AreEqual ("a", el.Name, "t11");
+
+ Assert.IsTrue (nods[4] is XmlElement, "t12");
+ el = nods[4] as XmlElement;
+ Assert.AreEqual ("b", el.Name, "t13");
+ }
+ }
+
+ [System.Web.Services.WebServiceBindingAttribute(Name="ConverterServiceSoap", Namespace="urn:mono-ws-tests")]
+ public class ConverterServiceExtraTest : System.Web.Services.Protocols.SoapHttpClientProtocol
+ {
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests" , Use=System.Web.Services.Description.SoapBindingUse.Encoded, ParameterStyle=SoapParameterStyle.Bare)]
+ public object GetTestInfo(string s, out string d) {
+ object[] results = this.Invoke("GetTestInfo", new object[] {s});
+ d = (string) results[1];
+ return ((object)(results[0]));
}
}
}
-// Web service test for WSDL document:
-// http://localhost:8080/ConvDocEncWra.asmx?wsdl
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
using System;
+using System.Threading;
using NUnit.Framework;
+using System.Web.Services.Protocols;
+using System.Xml;
using ConvDocEncWraTests.Soap;
namespace Localhost.ConvDocEncWraTests
{
[TestFixture]
- public class ConvDocEncWraTest: WebServiceTest
+ public class ConverterTest: WebServiceTest
{
[Test]
public void TestService ()
ConverterService cs = new ConverterService ();
cs.Login ("lluis");
cs.SetCurrencyRate ("EUR", 0.5);
- AssertEquals ("#1", 0.5, cs.GetCurrencyRate ("EUR"));
+ Assert.AreEqual (0.5, cs.GetCurrencyRate ("EUR"), "#1");
double res = cs.Convert ("EUR","USD",6);
- AssertEquals ("#2", (int)res, (int)12);
+ Assert.AreEqual ((int)res, (int)12, "#2");
CurrencyInfo[] infos = cs.GetCurrencyInfo ();
- AssertNotNull ("infos", infos);
+ Assert.IsNotNull (infos, "infos");
foreach (CurrencyInfo info in infos)
{
double val = 0;
- AssertNotNull ("info.Name", info.Name);
+ Assert.IsNotNull (info.Name, "info.Name");
switch (info.Name)
{
case "ZAR": val = 7.62645; break;
case "MXN": val = 10.5025; break;
}
- AssertEquals ("#3 " + info.Name, val, info.Rate);
+ Assert.AreEqual (val, info.Rate, "#3 " + info.Name);
}
+ cs.SetCurrencyRate ("EUR", 0.9);
+ }
+
+ // Async tests
+
+ ConverterService acs;
+ bool a1;
+ bool a2;
+ bool a3;
+ AutoResetEvent eve = new AutoResetEvent (false);
+
+ [Test]
+ public void AsyncTestService ()
+ {
+ IAsyncResult ar;
+ acs = new ConverterService ();
+
+ ar = acs.BeginLogin ("lluis", null, null);
+ acs.EndLogin (ar);
+
+ acs.BeginSetCurrencyRate ("EUR", 0.5, new AsyncCallback(Callback1), null);
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#0");
+ Assert.IsTrue (a1, "#1");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#2");
+ Assert.IsTrue (a2, "#3");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#4");
+ Assert.IsTrue (a3, "#5");
+ }
+
+ void Callback1 (IAsyncResult ar)
+ {
+ acs.EndSetCurrencyRate (ar);
+ acs.BeginGetCurrencyRate ("EUR", new AsyncCallback(Callback2), null);
+ }
+
+ void Callback2 (IAsyncResult ar)
+ {
+ double res = acs.EndGetCurrencyRate (ar);
+ a1 = (res == 0.5);
+ eve.Set ();
+
+ acs.BeginConvert ("EUR","USD",6, new AsyncCallback(Callback3), null);
+ }
+
+ void Callback3 (IAsyncResult ar)
+ {
+ double res = acs.EndConvert (ar);
+ a2 = (res == 12);
+ eve.Set ();
+
+ acs.BeginGetCurrencyInfo (new AsyncCallback(Callback4),null);
+ }
+
+ void Callback4 (IAsyncResult ar)
+ {
+ CurrencyInfo[] infos = acs.EndGetCurrencyInfo (ar);
+
+ foreach (CurrencyInfo info in infos)
+ {
+ double val = 0;
+ switch (info.Name)
+ {
+ case "USD": val = 1; break;
+ case "EUR": val = 0.5; break;
+ case "GBP": val = 0.611817; break;
+ case "JPY": val = 118.271; break;
+ case "CAD": val = 1.36338; break;
+ case "AUD": val = 1.51485; break;
+ case "CHF": val = 1.36915; break;
+ case "RUR": val = 30.4300; break;
+ case "CNY": val = 8.27740; break;
+ case "ZAR": val = 7.62645; break;
+ case "MXN": val = 10.5025; break;
+ }
+ a3 = (val == info.Rate);
+ if (!a3) break;
+ }
+ eve.Set ();
+ }
+
+ [Test]
+ public void TestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ try
+ {
+ cs.SetCurrencyRate ("EUR", 0.5);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void AsyncTestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ IAsyncResult ar = cs.BeginSetCurrencyRate ("EUR", 0.5, null, null);
+ try
+ {
+ cs.EndSetCurrencyRate (ar);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void TestObjectReturn ()
+ {
+ ConverterServiceExtraTest et = new ConverterServiceExtraTest ();
+
+ // Test the Discover method.
+ et.Url = "http://localhost:8080/ConvDocEncWra.asmx?disco";
+ et.Discover ();
+
+ string d;
+ object res = et.GetTestInfo ("hi", out d);
+
+ Assert.AreEqual ("iii", d, "t1");
+ Assert.IsNotNull (res, "t2");
+ Assert.IsTrue (res is XmlNode[], "t3");
+ XmlNode[] nods = res as XmlNode[];
+ Assert.AreEqual (5, nods.Length, "t4");
+
+ Assert.IsTrue (nods[0] is XmlAttribute, "t5");
+ XmlAttribute at = nods[0] as XmlAttribute;
+ Assert.AreEqual ("id", at.LocalName, "t6");
+
+ Assert.IsTrue (nods[1] is XmlAttribute, "t7");
+ at = nods[1] as XmlAttribute;
+ Assert.AreEqual ("type", at.LocalName, "t8");
+
+ Assert.IsTrue (nods[2] is XmlAttribute, "t9");
+ at = nods[2] as XmlAttribute;
+
+ Assert.IsTrue (nods[3] is XmlElement, "t10");
+ XmlElement el = nods[3] as XmlElement;
+ Assert.AreEqual ("a", el.Name, "t11");
+
+ Assert.IsTrue (nods[4] is XmlElement, "t12");
+ el = nods[4] as XmlElement;
+ Assert.AreEqual ("b", el.Name, "t13");
+ }
+ }
+
+ [System.Web.Services.WebServiceBindingAttribute(Name="ConverterServiceSoap", Namespace="urn:mono-ws-tests")]
+ public class ConverterServiceExtraTest : System.Web.Services.Protocols.SoapHttpClientProtocol
+ {
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests" , Use=System.Web.Services.Description.SoapBindingUse.Encoded, ParameterStyle=SoapParameterStyle.Wrapped)]
+ public object GetTestInfo(string s, out string d) {
+ object[] results = this.Invoke("GetTestInfo", new object[] {s});
+ d = (string) results[1];
+ return ((object)(results[0]));
}
}
}
-// Web service test for WSDL document:
-// http://localhost:8080/ConvDocLitBar.asmx?wsdl
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
using System;
+using System.Threading;
using NUnit.Framework;
+using System.Web.Services.Protocols;
+using System.Xml;
using ConvDocLitBarTests.Soap;
namespace Localhost.ConvDocLitBarTests
{
[TestFixture]
- public class ConvDocLitBarTest: WebServiceTest
+ public class ConverterTest: WebServiceTest
{
[Test]
public void TestService ()
ConverterService cs = new ConverterService ();
cs.Login ("lluis");
cs.SetCurrencyRate ("EUR", 0.5);
- AssertEquals ("#1", 0.5, cs.GetCurrencyRate ("EUR"));
+ Assert.AreEqual (0.5, cs.GetCurrencyRate ("EUR"), "#1");
double res = cs.Convert ("EUR","USD",6);
- AssertEquals ("#2", (int)res, (int)12);
+ Assert.AreEqual ((int)res, (int)12, "#2");
CurrencyInfo[] infos = cs.GetCurrencyInfo ();
+ Assert.IsNotNull (infos, "infos");
+
foreach (CurrencyInfo info in infos)
{
double val = 0;
+ Assert.IsNotNull (info.Name, "info.Name");
+
switch (info.Name)
{
case "USD": val = 1; break;
case "ZAR": val = 7.62645; break;
case "MXN": val = 10.5025; break;
}
- AssertEquals ("#3 " + info.Name, val, info.Rate);
+ Assert.AreEqual (val, info.Rate, "#3 " + info.Name);
}
+ cs.SetCurrencyRate ("EUR", 0.9);
+ }
+
+ // Async tests
+
+ ConverterService acs;
+ bool a1;
+ bool a2;
+ bool a3;
+ AutoResetEvent eve = new AutoResetEvent (false);
+
+ [Test]
+ public void AsyncTestService ()
+ {
+ IAsyncResult ar;
+ acs = new ConverterService ();
+
+ ar = acs.BeginLogin ("lluis", null, null);
+ acs.EndLogin (ar);
+
+ acs.BeginSetCurrencyRate ("EUR", 0.5, new AsyncCallback(Callback1), null);
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#0");
+ Assert.IsTrue (a1, "#1");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#2");
+ Assert.IsTrue (a2, "#3");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#4");
+ Assert.IsTrue (a3, "#5");
+ }
+
+ void Callback1 (IAsyncResult ar)
+ {
+ acs.EndSetCurrencyRate (ar);
+ acs.BeginGetCurrencyRate ("EUR", new AsyncCallback(Callback2), null);
+ }
+
+ void Callback2 (IAsyncResult ar)
+ {
+ double res = acs.EndGetCurrencyRate (ar);
+ a1 = (res == 0.5);
+ eve.Set ();
+
+ acs.BeginConvert ("EUR","USD",6, new AsyncCallback(Callback3), null);
+ }
+
+ void Callback3 (IAsyncResult ar)
+ {
+ double res = acs.EndConvert (ar);
+ a2 = (res == 12);
+ eve.Set ();
+
+ acs.BeginGetCurrencyInfo (new AsyncCallback(Callback4),null);
+ }
+
+ void Callback4 (IAsyncResult ar)
+ {
+ CurrencyInfo[] infos = acs.EndGetCurrencyInfo (ar);
+
+ foreach (CurrencyInfo info in infos)
+ {
+ double val = 0;
+ switch (info.Name)
+ {
+ case "USD": val = 1; break;
+ case "EUR": val = 0.5; break;
+ case "GBP": val = 0.611817; break;
+ case "JPY": val = 118.271; break;
+ case "CAD": val = 1.36338; break;
+ case "AUD": val = 1.51485; break;
+ case "CHF": val = 1.36915; break;
+ case "RUR": val = 30.4300; break;
+ case "CNY": val = 8.27740; break;
+ case "ZAR": val = 7.62645; break;
+ case "MXN": val = 10.5025; break;
+ }
+ a3 = (val == info.Rate);
+ if (!a3) break;
+ }
+ eve.Set ();
+ }
+
+ [Test]
+ public void TestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ try
+ {
+ cs.SetCurrencyRate ("EUR", 0.5);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void AsyncTestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ IAsyncResult ar = cs.BeginSetCurrencyRate ("EUR", 0.5, null, null);
+ try
+ {
+ cs.EndSetCurrencyRate (ar);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void TestObjectReturn ()
+ {
+ ConverterServiceExtraTest et = new ConverterServiceExtraTest ();
+
+ // Test the Discover method.
+ et.Url = "http://localhost:8080/ConvDocLitBar.asmx?disco";
+ et.Discover ();
+
+ string d;
+ object res = et.GetTestInfo ("hi", out d);
+
+ Assert.AreEqual ("iii", d, "t1");
+ Assert.IsNotNull (res, "t2");
+ Assert.IsTrue (res is XmlNode[], "t3");
+ XmlNode[] nods = res as XmlNode[];
+ Assert.AreEqual (5, nods.Length, "t4");
+
+ Assert.IsTrue (nods[0] is XmlAttribute, "t5");
+ XmlAttribute at = nods[0] as XmlAttribute;
+ Assert.AreEqual ("id", at.LocalName, "t6");
+
+ Assert.IsTrue (nods[1] is XmlAttribute, "t7");
+ at = nods[1] as XmlAttribute;
+ Assert.AreEqual ("type", at.LocalName, "t8");
+
+ Assert.IsTrue (nods[2] is XmlAttribute, "t9");
+ at = nods[2] as XmlAttribute;
+
+ Assert.IsTrue (nods[3] is XmlElement, "t10");
+ XmlElement el = nods[3] as XmlElement;
+ Assert.AreEqual ("a", el.Name, "t11");
+
+ Assert.IsTrue (nods[4] is XmlElement, "t12");
+ el = nods[4] as XmlElement;
+ Assert.AreEqual ("b", el.Name, "t13");
+ }
+ }
+
+ [System.Web.Services.WebServiceBindingAttribute(Name="ConverterServiceSoap", Namespace="urn:mono-ws-tests")]
+ public class ConverterServiceExtraTest : System.Web.Services.Protocols.SoapHttpClientProtocol
+ {
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests" , Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Bare)]
+ public object GetTestInfo(string s, out string d) {
+ object[] results = this.Invoke("GetTestInfo", new object[] {s});
+ d = (string) results[1];
+ return ((object)(results[0]));
}
}
}
-// Web service test for WSDL document:
-// http://localhost:8080/ConvDocLitWra.asmx?wsdl
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
using System;
using System.Threading;
using NUnit.Framework;
-using ConvDocLitWraTests.Soap;
using System.Web.Services.Protocols;
+using System.Xml;
+using ConvDocLitWraTests.Soap;
namespace Localhost.ConvDocLitWraTests
{
[TestFixture]
- public class ConvDocLitWraTest: WebServiceTest
+ public class ConverterTest: WebServiceTest
{
[Test]
public void TestService ()
{
ConverterService cs = new ConverterService ();
-
- // Test the Discover method.
- cs.Url = "http://localhost:8080/ConvDocLitWra.asmx?disco";
- cs.Discover ();
-
cs.Login ("lluis");
cs.SetCurrencyRate ("EUR", 0.5);
- AssertEquals ("#1", 0.5, cs.GetCurrencyRate ("EUR"));
+ Assert.AreEqual (0.5, cs.GetCurrencyRate ("EUR"), "#1");
double res = cs.Convert ("EUR","USD",6);
- AssertEquals ("#2", (int)res, (int)12);
+ Assert.AreEqual ((int)res, (int)12, "#2");
CurrencyInfo[] infos = cs.GetCurrencyInfo ();
+ Assert.IsNotNull (infos, "infos");
+
foreach (CurrencyInfo info in infos)
{
double val = 0;
+ Assert.IsNotNull (info.Name, "info.Name");
+
switch (info.Name)
{
case "USD": val = 1; break;
case "ZAR": val = 7.62645; break;
case "MXN": val = 10.5025; break;
}
- AssertEquals ("#3 " + info.Name, val, info.Rate);
+ Assert.AreEqual (val, info.Rate, "#3 " + info.Name);
}
cs.SetCurrencyRate ("EUR", 0.9);
}
acs.BeginSetCurrencyRate ("EUR", 0.5, new AsyncCallback(Callback1), null);
- Assert ("#0", eve.WaitOne (5000, false));
- Assert ("#1",a1);
+ Assert.IsTrue (eve.WaitOne (5000, false), "#0");
+ Assert.IsTrue (a1, "#1");
- Assert ("#2", eve.WaitOne (5000, false));
- Assert ("#3",a2);
+ Assert.IsTrue (eve.WaitOne (5000, false), "#2");
+ Assert.IsTrue (a2, "#3");
- Assert ("#4", eve.WaitOne (5000, false));
- Assert ("#5",a3);
+ Assert.IsTrue (eve.WaitOne (5000, false), "#4");
+ Assert.IsTrue (a3, "#5");
}
void Callback1 (IAsyncResult ar)
try
{
cs.SetCurrencyRate ("EUR", 0.5);
- Assert ("#0",false);
+ Assert.Fail ("#0");
}
catch (SoapException ex)
{
- Assert ("#1", ex.Message.IndexOf ("User not logged") != -1);
- AssertEquals ("#2", SoapException.ServerFaultCode, ex.Code);
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
}
}
try
{
cs.EndSetCurrencyRate (ar);
- Assert ("#0",false);
+ Assert.Fail ("#0");
}
catch (SoapException ex)
{
- Assert ("#1", ex.Message.IndexOf ("User not logged") != -1);
- AssertEquals ("#2", SoapException.ServerFaultCode, ex.Code);
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
}
}
+
+ [Test]
+ public void TestObjectReturn ()
+ {
+ ConverterServiceExtraTest et = new ConverterServiceExtraTest ();
+
+ // Test the Discover method.
+ et.Url = "http://localhost:8080/ConvDocLitWra.asmx?disco";
+ et.Discover ();
+
+ string d;
+ object res = et.GetTestInfo ("hi", out d);
+
+ Assert.AreEqual ("iii", d, "t1");
+ Assert.IsNotNull (res, "t2");
+ Assert.IsTrue (res is XmlNode[], "t3");
+ XmlNode[] nods = res as XmlNode[];
+ Assert.AreEqual (5, nods.Length, "t4");
+
+ Assert.IsTrue (nods[0] is XmlAttribute, "t5");
+ XmlAttribute at = nods[0] as XmlAttribute;
+ Assert.AreEqual ("id", at.LocalName, "t6");
+
+ Assert.IsTrue (nods[1] is XmlAttribute, "t7");
+ at = nods[1] as XmlAttribute;
+ Assert.AreEqual ("type", at.LocalName, "t8");
+
+ Assert.IsTrue (nods[2] is XmlAttribute, "t9");
+ at = nods[2] as XmlAttribute;
+
+ Assert.IsTrue (nods[3] is XmlElement, "t10");
+ XmlElement el = nods[3] as XmlElement;
+ Assert.AreEqual ("a", el.Name, "t11");
+
+ Assert.IsTrue (nods[4] is XmlElement, "t12");
+ el = nods[4] as XmlElement;
+ Assert.AreEqual ("b", el.Name, "t13");
+ }
+ }
+
+ [System.Web.Services.WebServiceBindingAttribute(Name="ConverterServiceSoap", Namespace="urn:mono-ws-tests")]
+ public class ConverterServiceExtraTest : System.Web.Services.Protocols.SoapHttpClientProtocol
+ {
+ [System.Web.Services.Protocols.SoapDocumentMethodAttribute("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests" , Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Wrapped)]
+ public object GetTestInfo(string s, out string d) {
+ object[] results = this.Invoke("GetTestInfo", new object[] {s});
+ d = (string) results[1];
+ return ((object)(results[0]));
+ }
}
}
-// Web service test for WSDL document:
-// http://localhost:8080/ConvRpc.asmx?wsdl
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
using System;
-using System.Web.Services;
-using System.Xml.Serialization;
-using System.Xml;
+using System.Threading;
using NUnit.Framework;
+using System.Web.Services.Protocols;
+using System.Xml;
using ConvRpcTests.Soap;
namespace Localhost.ConvRpcTests
{
[TestFixture]
- public class ConvRpcTest: WebServiceTest
+ public class ConverterTest: WebServiceTest
{
[Test]
public void TestService ()
ConverterService cs = new ConverterService ();
cs.Login ("lluis");
cs.SetCurrencyRate ("EUR", 0.5);
- AssertEquals ("#1", 0.5, cs.GetCurrencyRate ("EUR"));
+ Assert.AreEqual (0.5, cs.GetCurrencyRate ("EUR"), "#1");
double res = cs.Convert ("EUR","USD",6);
- AssertEquals ("#2", (int)res, (int)12);
+ Assert.AreEqual ((int)res, (int)12, "#2");
CurrencyInfo[] infos = cs.GetCurrencyInfo ();
+ Assert.IsNotNull (infos, "infos");
+
+ foreach (CurrencyInfo info in infos)
+ {
+ double val = 0;
+ Assert.IsNotNull (info.Name, "info.Name");
+
+ switch (info.Name)
+ {
+ case "USD": val = 1; break;
+ case "EUR": val = 0.5; break;
+ case "GBP": val = 0.611817; break;
+ case "JPY": val = 118.271; break;
+ case "CAD": val = 1.36338; break;
+ case "AUD": val = 1.51485; break;
+ case "CHF": val = 1.36915; break;
+ case "RUR": val = 30.4300; break;
+ case "CNY": val = 8.27740; break;
+ case "ZAR": val = 7.62645; break;
+ case "MXN": val = 10.5025; break;
+ }
+ Assert.AreEqual (val, info.Rate, "#3 " + info.Name);
+ }
+ cs.SetCurrencyRate ("EUR", 0.9);
+ }
+
+ // Async tests
+
+ ConverterService acs;
+ bool a1;
+ bool a2;
+ bool a3;
+ AutoResetEvent eve = new AutoResetEvent (false);
+
+ [Test]
+ public void AsyncTestService ()
+ {
+ IAsyncResult ar;
+ acs = new ConverterService ();
+
+ ar = acs.BeginLogin ("lluis", null, null);
+ acs.EndLogin (ar);
+
+ acs.BeginSetCurrencyRate ("EUR", 0.5, new AsyncCallback(Callback1), null);
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#0");
+ Assert.IsTrue (a1, "#1");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#2");
+ Assert.IsTrue (a2, "#3");
+
+ Assert.IsTrue (eve.WaitOne (5000, false), "#4");
+ Assert.IsTrue (a3, "#5");
+ }
+
+ void Callback1 (IAsyncResult ar)
+ {
+ acs.EndSetCurrencyRate (ar);
+ acs.BeginGetCurrencyRate ("EUR", new AsyncCallback(Callback2), null);
+ }
+
+ void Callback2 (IAsyncResult ar)
+ {
+ double res = acs.EndGetCurrencyRate (ar);
+ a1 = (res == 0.5);
+ eve.Set ();
+
+ acs.BeginConvert ("EUR","USD",6, new AsyncCallback(Callback3), null);
+ }
+
+ void Callback3 (IAsyncResult ar)
+ {
+ double res = acs.EndConvert (ar);
+ a2 = (res == 12);
+ eve.Set ();
+
+ acs.BeginGetCurrencyInfo (new AsyncCallback(Callback4),null);
+ }
+
+ void Callback4 (IAsyncResult ar)
+ {
+ CurrencyInfo[] infos = acs.EndGetCurrencyInfo (ar);
+
foreach (CurrencyInfo info in infos)
{
double val = 0;
case "ZAR": val = 7.62645; break;
case "MXN": val = 10.5025; break;
}
- AssertEquals ("#3 " + info.Name, val, info.Rate);
+ a3 = (val == info.Rate);
+ if (!a3) break;
+ }
+ eve.Set ();
+ }
+
+ [Test]
+ public void TestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ try
+ {
+ cs.SetCurrencyRate ("EUR", 0.5);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
+ }
+ }
+
+ [Test]
+ public void AsyncTestException ()
+ {
+ ConverterService cs = new ConverterService ();
+ IAsyncResult ar = cs.BeginSetCurrencyRate ("EUR", 0.5, null, null);
+ try
+ {
+ cs.EndSetCurrencyRate (ar);
+ Assert.Fail ("#0");
+ }
+ catch (SoapException ex)
+ {
+ Assert.IsTrue (ex.Message.IndexOf ("User not logged") != -1, "#1");
+ Assert.AreEqual (SoapException.ServerFaultCode, ex.Code, "#2");
}
}
public void TestObjectReturn ()
{
ConverterServiceExtraTest et = new ConverterServiceExtraTest ();
+
+ // Test the Discover method.
+ et.Url = "http://localhost:8080/ConvRpc.asmx?disco";
+ et.Discover ();
+
string d;
object res = et.GetTestInfo ("hi", out d);
- AssertEquals ("t1", "iii", d);
- AssertNotNull ("t2", res);
- Assert ("t3", res is XmlNode[]);
+ Assert.AreEqual ("iii", d, "t1");
+ Assert.IsNotNull (res, "t2");
+ Assert.IsTrue (res is XmlNode[], "t3");
XmlNode[] nods = res as XmlNode[];
- AssertEquals ("t4", 5, nods.Length);
+ Assert.AreEqual (5, nods.Length, "t4");
- Assert ("t5", nods[0] is XmlAttribute);
+ Assert.IsTrue (nods[0] is XmlAttribute, "t5");
XmlAttribute at = nods[0] as XmlAttribute;
- AssertEquals ("t6", "id", at.LocalName);
+ Assert.AreEqual ("id", at.LocalName, "t6");
- Assert ("t7", nods[1] is XmlAttribute);
+ Assert.IsTrue (nods[1] is XmlAttribute, "t7");
at = nods[1] as XmlAttribute;
- AssertEquals ("t8", "type", at.LocalName);
+ Assert.AreEqual ("type", at.LocalName, "t8");
- Assert ("t9", nods[2] is XmlAttribute);
+ Assert.IsTrue (nods[2] is XmlAttribute, "t9");
at = nods[2] as XmlAttribute;
- Assert ("t10", nods[3] is XmlElement);
+ Assert.IsTrue (nods[3] is XmlElement, "t10");
XmlElement el = nods[3] as XmlElement;
- AssertEquals ("t11", "a", el.Name);
+ Assert.AreEqual ("a", el.Name, "t11");
- Assert ("t12", nods[4] is XmlElement);
+ Assert.IsTrue (nods[4] is XmlElement, "t12");
el = nods[4] as XmlElement;
- AssertEquals ("t13", "b", el.Name);
- }
+ Assert.AreEqual ("b", el.Name, "t13");
+ }
}
[System.Web.Services.WebServiceBindingAttribute(Name="ConverterServiceSoap", Namespace="urn:mono-ws-tests")]
public class ConverterServiceExtraTest : System.Web.Services.Protocols.SoapHttpClientProtocol
{
- public ConverterServiceExtraTest() {
- this.Url = "http://localhost:8080/ConvRpc.asmx";
- }
-
- [System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests")]
+ [System.Web.Services.Protocols.SoapRpcMethodAttribute("urn:mono-ws-tests/GetTestInfo", RequestNamespace="urn:mono-ws-tests", ResponseNamespace="urn:mono-ws-tests" )]
public object GetTestInfo(string s, out string d) {
object[] results = this.Invoke("GetTestInfo", new object[] {s});
d = (string) results[1];
DataSet dset = service.QueryData ("some query");
DataTable t = dset.Tables["PhoneNumbers"];
- AssertNotNull ("#1", t);
- AssertEquals ("#2", 2, t.Rows.Count);
+ Assert.IsNotNull (t, "#1");
+ Assert.AreEqual (2, t.Rows.Count, "#2");
DataRow row = t.Rows[0];
- AssertEquals ("#3", "Lluis", row["name"]);
- AssertEquals ("#4", "23452345", row["home"]);
+ Assert.AreEqual ("Lluis", row["name"], "#3");
+ Assert.AreEqual ("23452345", row["home"], "#4");
row = t.Rows[1];
- AssertEquals ("#5", "Pep", row["name"]);
- AssertEquals ("#6", "435345", row["home"]);
+ Assert.AreEqual ("Pep", row["name"], "#5");
+ Assert.AreEqual ("435345", row["home"], "#6");
DataRow newRow = t.NewRow();
newRow["name"] = "Pau";
newRow["home"] = "9028374";
t.Rows.Add (newRow);
int n = service.SaveData (dset);
- AssertEquals ("#7", 3, n);
+ Assert.AreEqual (3, n, "#7");
}
}
}
correctionsCorrection[] arr = new correctionsCorrection[2]{c,c};
arr = s.SpellCheck(ref title,ref url,arr);
- AssertEquals ("t1", 2, arr.Length);
+ Assert.AreEqual (2, arr.Length, "t1");
for (int i =0; i< arr.Length ; i++)
{
c = arr[i];
- AssertNotNull ("t2."+i, c);
- AssertEquals ("t3."+i, "bye", c.word);
- AssertNotNull ("t4."+i, c.suggestions);
- AssertEquals ("t5."+i, 2, c.suggestions.Length);
- AssertEquals ("t6."+i, "end", c.suggestions[0]);
- AssertEquals ("t7."+i, "test", c.suggestions[1]);
+ Assert.IsNotNull (c, "t2."+i);
+ Assert.AreEqual ("bye", c.word, "t3."+i);
+ Assert.IsNotNull (c.suggestions, "t4."+i);
+ Assert.AreEqual (2, c.suggestions.Length, "t5."+i);
+ Assert.AreEqual ("end", c.suggestions[0], "t6."+i);
+ Assert.AreEqual ("test", c.suggestions[1], "t7."+i);
}
- AssertEquals ("t8", "hello", title);
- AssertEquals ("t9", "tmp", url);
+ Assert.AreEqual ("hello", title, "t8");
+ Assert.AreEqual ("tmp", url, "t9");
}
}
}
{
IncludeTest test = new IncludeTest();
object[] data = test.foo ();
- AssertNotNull (data);
+ Assert.IsNotNull (data);
ComplexThing c1 = data[0] as ComplexThing;
- AssertNotNull (c1);
- AssertEquals ("abc",c1.name);
+ Assert.IsNotNull (c1);
+ Assert.AreEqual ("abc",c1.name);
ComplexThing c2 = data[1] as ComplexThing;
- AssertNotNull (c2);
- AssertEquals ("xyz",c2.name);
+ Assert.IsNotNull (c2);
+ Assert.AreEqual ("xyz",c2.name);
}
}
}
s.CookieContainer = new CookieContainer ();
s.Reset ();
for (int n=1; n<10; n++)
- AssertEquals ("t"+n, n, s.AddOne ());
+ Assert.AreEqual (n, s.AddOne (), "t"+n);
}
}
}
nodes = data.GetTabStruct ("hello", nodes);
Check ("GetTabStruct", nodes);
- Assert ("RebuildTabList 1", data.RebuildTabList (true));
- Assert ("RebuildTabList 2", !data.RebuildTabList (false));
+ Assert.IsTrue (data.RebuildTabList (true), "RebuildTabList 1");
+ Assert.IsTrue (!data.RebuildTabList (false), "RebuildTabList 2");
- Assert ("RebuildTabStruct 1", data.RebuildTabStruct ("a", true));
- Assert ("RebuildTabStruct 2", !data.RebuildTabStruct ("b", false));
+ Assert.IsTrue (data.RebuildTabStruct ("a", true), "RebuildTabStruct 1");
+ Assert.IsTrue (!data.RebuildTabStruct ("b", false), "RebuildTabStruct 2");
}
void Check (string met, XmlNode[] nodes)
{
- AssertNotNull (met + " #1", nodes);
- AssertEquals (met + " #2", 2, nodes.Length);
- AssertEquals (met + " #3", "<one someAtt=\"someValue\" xmlns=\"\" />", nodes[0].OuterXml);
- AssertEquals (met + " #4", "<two someAtt=\"someValue\" xmlns=\"\" />", nodes[1].OuterXml);
+ Assert.IsNotNull (nodes, met + " #1");
+ Assert.AreEqual (2, nodes.Length, met + " #2");
+ Assert.AreEqual ("<one someAtt=\"someValue\" xmlns=\"\" />", nodes[0].OuterXml, met + " #3");
+ Assert.AreEqual ("<two someAtt=\"someValue\" xmlns=\"\" />", nodes[1].OuterXml, met + " #4");
}
}
}
--- /dev/null
+<html>
+<head>
+<title>wsdl tests</title>
+<LINK rel="stylesheet" type="text/css" href="cm/cormissing.css">
+<SCRIPT src="cm/cormissing.js"></SCRIPT>
+</head>
+<body bgcolor="#ffffff" text="#000000">
<%@ WebService Language="c#" Codebehind="ConverterService.asmx.cs" Class="WebServiceTests.ConverterService" %>
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
+
using System;
using System.Collections;
using System.Xml.Serialization;
dada = 1;
}
+ [WebMethod]
+ public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
+ {
+ return null;
+ }
+
void CheckUser ()
{
if (userInfo == null)
throw new SoapException ("User not logged", SoapException.ServerFaultCode);
}
+
+ [WebMethod]
+ [return: SoapElement("retret")]
+ public MyInfo GetTestInfo (string s, out string d)
+ {
+ d = "iii";
+ return new MyInfo();
+ }
+ }
+
+ public class MyInfo
+ {
+ public int a = 4;
+ public string b = "hi";
}
}
<%@ WebService Language="c#" Codebehind="ConverterService.asmx.cs" Class="WebServiceTests.ConverterService" %>
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
+
using System;
using System.Collections;
using System.Xml.Serialization;
}
[WebMethod]
- public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
+ public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
{
return null;
}
if (userInfo == null)
throw new SoapException ("User not logged", SoapException.ServerFaultCode);
}
+
+ [WebMethod]
+ [return: SoapElement("retret")]
+ public MyInfo GetTestInfo (string s, out string d)
+ {
+ d = "iii";
+ return new MyInfo();
+ }
+ }
+
+ public class MyInfo
+ {
+ public int a = 4;
+ public string b = "hi";
}
}
<%@ WebService Language="c#" Codebehind="ConverterService.asmx.cs" Class="WebServiceTests.ConverterService" %>
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
+
using System;
using System.Collections;
using System.Xml.Serialization;
[WebServiceAttribute (Namespace="urn:mono-ws-tests", Description="Web service that can make currency conversions")]
[SoapDocumentServiceAttribute (Use=SoapBindingUse.Literal, ParameterStyle=SoapParameterStyle.Bare)]
- public class ConverterService
+ public class ConverterService : System.Web.Services.WebService
{
static int userCount = 0;
static Hashtable conversionTable;
dada = 1;
}
+ [WebMethod]
+ public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
+ {
+ return null;
+ }
+
void CheckUser ()
{
if (userInfo == null)
throw new SoapException ("User not logged", SoapException.ServerFaultCode);
}
+
+ [WebMethod]
+ [return: XmlElement("retret")]
+ public MyInfo GetTestInfo (string s, out string d)
+ {
+ d = "iii";
+ return new MyInfo();
+ }
+ }
+
+ public class MyInfo
+ {
+ public int a = 4;
+ public string b = "hi";
}
}
<%@ WebService Language="c#" Codebehind="ConverterService.asmx.cs" Class="WebServiceTests.ConverterService" %>
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
+
using System;
using System.Collections;
using System.Xml.Serialization;
}
[WebMethod]
- public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
+ public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
{
return null;
}
if (userInfo == null)
throw new SoapException ("User not logged", SoapException.ServerFaultCode);
}
+
+ [WebMethod]
+ [return: XmlElement("retret")]
+ public MyInfo GetTestInfo (string s, out string d)
+ {
+ d = "iii";
+ return new MyInfo();
+ }
+ }
+
+ public class MyInfo
+ {
+ public int a = 4;
+ public string b = "hi";
}
}
<%@ WebService Language="c#" Codebehind="ConverterService.asmx.cs" Class="WebServiceTests.ConverterService" %>
+/*
+WARNING: This code was generated by a tool.
+Changes to this file will be lost if the code is regenerated
+*/
+
using System;
using System.Collections;
using System.Xml.Serialization;
}
[WebServiceAttribute (Namespace="urn:mono-ws-tests", Description="Web service that can make currency conversions")]
- [SoapRpcServiceAttribute ()]
+ [SoapRpcServiceAttribute()]
public class ConverterService : System.Web.Services.WebService
{
static int userCount = 0;
}
[WebMethod]
- [return: SoapElement("retret")]
- public MyInfo GetTestInfo (string s, out string d)
+ public System.Collections.Specialized.StringCollection TestArrays (string[] info, string lang)
{
- d = "iii";
- return new MyInfo();
+ return null;
}
void CheckUser ()
if (userInfo == null)
throw new SoapException ("User not logged", SoapException.ServerFaultCode);
}
+
+ [WebMethod]
+ [return: SoapElement("retret")]
+ public MyInfo GetTestInfo (string s, out string d)
+ {
+ d = "iii";
+ return new MyInfo();
+ }
}
-
+
public class MyInfo
{
public int a = 4;
if (args[0] == "gp")
{
- BuildProxies (GetArg (args,1) == "all");
+ BuildProxies (GetArg (args,1));
}
else if (args[0] == "gc")
{
{
MsFix (GetArg (args,1));
}
+ else if (args[0] == "genfiles")
+ {
+ GenerateFiles (GetArg (args,1));
+ }
SaveInfo ();
Console.WriteLine ("{0,-3} {1}", serverCounts[n], serverNames[n]);
}
- static void BuildProxies (bool buildAll)
+ static void BuildProxies (string host)
{
Console.WriteLine ();
Console.WriteLine ("Generating proxies");
XmlElement ele = doc.CreateElement ("errors");
doc.AppendChild (ele);
+ bool buildAll = host == "*";
+ if (buildAll) host = null;
+
ArrayList proxies = new ArrayList ();
- foreach (ServiceData fd in services.services)
+ foreach (ServiceData fd in services.services) {
+ if (host != null && host != new Uri (fd.Wsdl).Host) continue;
BuildProxy (fd, buildAll, proxies, ele);
+ }
StreamWriter sw = new StreamWriter (Path.Combine (basePath, "proxies.sources"));
foreach (string f in proxies)
sr.Close ();
}
+ static void GenerateFiles (string templateFile)
+ {
+ XmlDocument doc = new XmlDocument ();
+ doc.Load (templateFile);
+
+ XmlNodeList targets = doc.SelectNodes ("fileGeneration/targets/target");
+ XmlElement gvarset = (XmlElement) doc.SelectSingleNode ("fileGeneration/vars[@name='_global']");
+
+ foreach (XmlElement node in targets) {
+ string tid = node.GetAttribute ("template");
+ string file = node.GetAttribute ("file");
+ XmlElement xtemp = (XmlElement) doc.SelectSingleNode ("fileGeneration/templates/template[@id='" + tid + "']");
+ if (xtemp == null) throw new Exception ("Template " + tid + " not found");
+ string tempFile = xtemp.GetAttribute ("file");
+
+ StreamReader sr = new StreamReader (tempFile);
+ string template = sr.ReadToEnd ();
+ sr.Close ();
+
+ string content = ReplaceVars (template, node);
+ content = ReplaceVars (content, gvarset);
+
+ StreamWriter sw = new StreamWriter (file);
+ sw.Write (content);
+ sw.Close ();
+ Console.WriteLine ("Writen " + file);
+ }
+ }
+
+ static string ReplaceVars (string content, XmlElement root)
+ {
+ XmlNodeList nodes = root.SelectNodes ("var");
+ foreach (XmlElement elem in nodes) {
+ string include = elem.GetAttribute ("include");
+ if (include != "") {
+ XmlElement varset = (XmlElement) root.OwnerDocument.SelectSingleNode ("fileGeneration/vars[@name='" + include + "']");
+ if (varset == null) throw new Exception ("varset '" + include + "' not found");
+ content = ReplaceVars (content, varset);
+ }
+ else {
+ content = content.Replace ("$" + elem.GetAttribute ("name") + "$", elem.InnerText);
+ }
+ }
+
+ return content;
+ }
+
static void RegisterFailure (ServiceData sd)
{
ServiceStatus status = null;