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

View File

@ -0,0 +1,8 @@
2009-10-07 Atsushi Enomoto <atsushi@ximian.com>
* WebScriptServiceHostFactoryTest.cs : add tests for contract and
wrapped validity.
2009-10-02 Atsushi Enomoto <atsushi@ximian.com>
* WebScriptServiceHostFactoryTest.cs : new test.

View File

@ -0,0 +1,93 @@
#if !MOBILE
using System;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Channels;
using System.ServiceModel.Web;
using NUnit.Framework;
namespace MonoTests.System.ServiceModel.Activation
{
class MyHostFactory : WebScriptServiceHostFactory
{
public ServiceHost DoCreateServiceHost (Type type, params Uri [] baseAddresses)
{
return CreateServiceHost (type, baseAddresses);
}
}
[TestFixture]
public class WebScriptServiceHostFactoryTest
{
[Test]
public void CreateServiceHost ()
{
var f = new MyHostFactory ();
var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ("http://localhost:37564")});
Assert.IsFalse (host is WebServiceHost, "#1");
host.Open ();
host.Close ();
}
[Test]
[ExpectedException (typeof (NotSupportedException))]
public void ResponseWrappedIsInvalid ()
{
var f = new MyHostFactory ();
var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ("http://localhost:37564")});
host.Open (); // should raise an error here.
}
[Test]
[ExpectedException (typeof (InvalidOperationException))]
public void MultipleContract ()
{
var f = new MyHostFactory ();
var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ("http://localhost:37564")});
host.Open ();
}
}
[ServiceContract]
public interface ITestService
{
[OperationContract]
string DoWork (string s1, string s2);
}
public class TestService : ITestService
{
public string DoWork (string s1, string s2)
{
return s1 + s2;
}
}
[ServiceContract]
public interface ITestService2
{
[OperationContract]
[WebGet (BodyStyle = WebMessageBodyStyle.WrappedResponse)]
string DoWork (string s1, string s2);
}
public class TestService2 : ITestService2
{
public string DoWork (string s1, string s2)
{
return s1 + s2;
}
}
public class TestServiceMultiple : ITestService, ITestService2
{
public string DoWork (string s1, string s2)
{
return s1 + s2;
}
}
}
#endif