1 #if !MOBILE && !MONOMAC
4 using System.ServiceModel;
5 using System.ServiceModel.Activation;
6 using System.ServiceModel.Channels;
7 using System.ServiceModel.Web;
10 using MonoTests.Helpers;
12 namespace MonoTests.System.ServiceModel.Activation
14 class MyHostFactory : WebScriptServiceHostFactory
16 public ServiceHost DoCreateServiceHost (Type type, params Uri [] baseAddresses)
18 return CreateServiceHost (type, baseAddresses);
23 public class WebScriptServiceHostFactoryTest
26 public void CreateServiceHost ()
28 var port = NetworkHelpers.FindFreePort ();
29 var f = new MyHostFactory ();
30 var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ($"http://localhost:{port}")});
31 Assert.IsFalse (host is WebServiceHost, "#1");
37 [ExpectedException (typeof (NotSupportedException))]
38 public void ResponseWrappedIsInvalid ()
40 var port = NetworkHelpers.FindFreePort ();
41 var f = new MyHostFactory ();
42 var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ($"http://localhost:{port}")});
43 host.Open (); // should raise an error here.
47 [ExpectedException (typeof (InvalidOperationException))]
48 public void MultipleContract ()
50 var port = NetworkHelpers.FindFreePort ();
51 var f = new MyHostFactory ();
52 var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ($"http://localhost:{port}")});
59 public interface ITestService
62 string DoWork (string s1, string s2);
65 public class TestService : ITestService
67 public string DoWork (string s1, string s2)
74 public interface ITestService2
77 [WebGet (BodyStyle = WebMessageBodyStyle.WrappedResponse)]
78 string DoWork (string s1, string s2);
81 public class TestService2 : ITestService2
83 public string DoWork (string s1, string s2)
89 public class TestServiceMultiple : ITestService, ITestService2
91 public string DoWork (string s1, string s2)