[System] Fix TDS 7.0 prepared InputOutput parameter info
[mono.git] / mcs / class / System.ServiceModel.Web / Test / System.ServiceModel.Activation / WebScriptServiceHostFactoryTest.cs
1 #if !MOBILE && !MONOMAC
2
3 using System;
4 using System.ServiceModel;
5 using System.ServiceModel.Activation;
6 using System.ServiceModel.Channels;
7 using System.ServiceModel.Web;
8 using NUnit.Framework;
9
10 namespace MonoTests.System.ServiceModel.Activation
11 {
12         class MyHostFactory : WebScriptServiceHostFactory
13         {
14                 public ServiceHost DoCreateServiceHost (Type type, params Uri [] baseAddresses)
15                 {
16                         return CreateServiceHost (type, baseAddresses);
17                 }
18         }
19
20         [TestFixture]
21         public class WebScriptServiceHostFactoryTest
22         {
23                 [Test]
24                 public void CreateServiceHost ()
25                 {
26                         var f = new MyHostFactory ();
27                         var host = f.DoCreateServiceHost (typeof (TestService), new Uri [] {new Uri ("http://localhost:37564")});
28                         Assert.IsFalse (host is WebServiceHost, "#1");
29                         host.Open ();
30                         host.Close ();
31                 }
32
33                 [Test]
34                 [ExpectedException (typeof (NotSupportedException))]
35                 public void ResponseWrappedIsInvalid ()
36                 {
37                         var f = new MyHostFactory ();
38                         var host = f.DoCreateServiceHost (typeof (TestService2), new Uri [] {new Uri ("http://localhost:37564")});
39                         host.Open (); // should raise an error here.
40                 }
41
42                 [Test]
43                 [ExpectedException (typeof (InvalidOperationException))]
44                 public void MultipleContract ()
45                 {
46                         var f = new MyHostFactory ();
47                         var host = f.DoCreateServiceHost (typeof (TestServiceMultiple), new Uri [] {new Uri ("http://localhost:37564")});
48                         host.Open ();
49                 }
50
51         }
52
53         [ServiceContract]
54         public interface ITestService
55         {
56                 [OperationContract]
57                 string DoWork (string s1, string s2);
58         }
59
60         public class TestService : ITestService
61         {
62                 public string DoWork (string s1, string s2)
63                 {
64                         return s1 + s2;
65                 }
66         }
67
68         [ServiceContract]
69         public interface ITestService2
70         {
71                 [OperationContract]
72                 [WebGet (BodyStyle = WebMessageBodyStyle.WrappedResponse)]
73                 string DoWork (string s1, string s2);
74         }
75
76         public class TestService2 : ITestService2
77         {
78                 public string DoWork (string s1, string s2)
79                 {
80                         return s1 + s2;
81                 }
82         }
83
84         public class TestServiceMultiple : ITestService, ITestService2
85         {
86                 public string DoWork (string s1, string s2)
87                 {
88                         return s1 + s2;
89                 }
90         }
91 }
92
93 #endif