5 // Martin Baulig <martin.baulig@xamarin.com>
7 // Copyright (c) 2012 Xamarin Inc. (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 using System.Collections.Generic;
32 using System.ServiceModel;
33 using System.ServiceModel.Channels;
34 using System.ServiceModel.Description;
35 using NUnit.Framework;
36 using NUnit.Framework.Constraints;
37 using NUnit.Framework.SyntaxHelpers;
39 using WS = System.Web.Services.Description;
41 namespace MonoTests.System.ServiceModel.MetadataTests {
44 * This class is abstract to allow it to be run multiple times with
45 * different TestContexts.
47 [Category ("MetadataTests")]
48 public abstract class ImportTests {
50 public abstract TestContext Context {
54 protected MetadataSet GetMetadata (string name, out TestLabel label)
56 label = new TestLabel (name);
57 return Context.GetMetadata (name);
61 public virtual void BasicHttp ()
64 var doc = GetMetadata ("BasicHttp", out label);
66 BindingTestAssertions.BasicHttpBinding (
67 Context, doc, BasicHttpSecurityMode.None, label);
71 public virtual void BasicHttp_TransportSecurity ()
74 var doc = GetMetadata ("BasicHttp_TransportSecurity", out label);
76 BindingTestAssertions.BasicHttpBinding (
77 Context, doc, BasicHttpSecurityMode.Transport, label);
81 [Category ("NotWorking")]
82 public virtual void BasicHttp_MessageSecurity ()
85 var doc = GetMetadata ("BasicHttp_MessageSecurity", out label);
87 BindingTestAssertions.BasicHttpBinding (
88 Context, doc, BasicHttpSecurityMode.Message, label);
92 [Category ("NotWorking")]
93 public virtual void BasicHttp_TransportWithMessageCredential ()
96 var doc = GetMetadata ("BasicHttp_TransportWithMessageCredential", out label);
98 BindingTestAssertions.BasicHttpBinding (
99 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential, label);
103 public virtual void BasicHttp_Mtom ()
106 var doc = GetMetadata ("BasicHttp_Mtom", out label);
108 BindingTestAssertions.BasicHttpBinding (
109 Context, doc, WSMessageEncoding.Mtom, label);
113 public virtual void BasicHttp_NtlmAuth ()
116 var doc = GetMetadata ("BasicHttp_NtlmAuth", out label);
118 BindingTestAssertions.BasicHttpBinding (
119 Context, doc, BasicHttpSecurityMode.TransportCredentialOnly,
120 WSMessageEncoding.Text, HttpClientCredentialType.Ntlm,
121 AuthenticationSchemes.Ntlm, label);
126 public virtual void BasicHttps ()
129 var doc = GetMetadata ("BasicHttps", out label);
131 BindingTestAssertions.BasicHttpsBinding (
132 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
133 HttpClientCredentialType.None, AuthenticationSchemes.Anonymous,
138 public virtual void BasicHttps_NtlmAuth ()
141 var doc = GetMetadata ("BasicHttps_NtlmAuth", out label);
143 BindingTestAssertions.BasicHttpsBinding (
144 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
145 HttpClientCredentialType.Ntlm, AuthenticationSchemes.Ntlm,
150 [Category ("NotWorking")]
151 public virtual void BasicHttps_Certificate ()
154 var doc = GetMetadata ("BasicHttps_Certificate", out label);
156 BindingTestAssertions.BasicHttpsBinding (
157 Context, doc, BasicHttpSecurityMode.Transport, WSMessageEncoding.Text,
158 HttpClientCredentialType.Certificate, AuthenticationSchemes.Anonymous,
163 [Category ("NotWorking")]
164 public virtual void BasicHttps_TransportWithMessageCredential ()
167 var doc = GetMetadata ("BasicHttps_TransportWithMessageCredential", out label);
169 BindingTestAssertions.BasicHttpsBinding (
170 Context, doc, BasicHttpSecurityMode.TransportWithMessageCredential,
171 WSMessageEncoding.Text, HttpClientCredentialType.None,
172 AuthenticationSchemes.Anonymous, label);
177 public virtual void NetTcp ()
180 var doc = GetMetadata ("NetTcp", out label);
182 BindingTestAssertions.NetTcpBinding (
183 Context, doc, SecurityMode.None, false, TransferMode.Buffered, label);
187 public virtual void NetTcp_TransferMode ()
190 var doc = GetMetadata ("NetTcp_TransferMode", out label);
192 BindingTestAssertions.NetTcpBinding (
193 Context, doc, SecurityMode.None, false,
194 TransferMode.Streamed, label);
198 public virtual void NetTcp_TransportSecurity ()
201 var doc = GetMetadata ("NetTcp_TransportSecurity", out label);
203 BindingTestAssertions.NetTcpBinding (
204 Context, doc, SecurityMode.Transport, false,
205 TransferMode.Buffered, label);
209 [Category ("NotWorking")]
210 public virtual void NetTcp_MessageSecurity ()
213 var doc = GetMetadata ("NetTcp_MessageSecurity", out label);
215 BindingTestAssertions.NetTcpBinding (
216 Context, doc, SecurityMode.Message, false,
217 TransferMode.Buffered, label);
221 [Category ("NotWorking")]
222 public virtual void NetTcp_TransportWithMessageCredential ()
225 var doc = GetMetadata ("NetTcp_TransportWithMessageCredential", out label);
227 BindingTestAssertions.NetTcpBinding (
228 Context, doc, SecurityMode.TransportWithMessageCredential, false,
229 TransferMode.Buffered, label);
233 public virtual void NetTcp_Binding ()
235 var label = new TestLabel ("NetTcp_Binding");
237 label.EnterScope ("None");
238 BindingTestAssertions.CheckNetTcpBinding (
239 new NetTcpBinding (SecurityMode.None), SecurityMode.None,
240 false, TransferMode.Buffered, label);
243 label.EnterScope ("Transport");
244 BindingTestAssertions.CheckNetTcpBinding (
245 new NetTcpBinding (SecurityMode.Transport), SecurityMode.Transport,
246 false, TransferMode.Buffered, label);
251 [Category ("NotWorking")]
252 public virtual void NetTcp_Binding2 ()
254 var label = new TestLabel ("NetTcp_Binding2");
256 label.EnterScope ("TransportWithMessageCredential");
257 BindingTestAssertions.CheckNetTcpBinding (
258 new NetTcpBinding (SecurityMode.TransportWithMessageCredential),
259 SecurityMode.TransportWithMessageCredential, false,
260 TransferMode.Buffered, label);
265 [Category ("NotWorking")]
266 public virtual void NetTcp_ReliableSession ()
269 var doc = GetMetadata ("NetTcp_ReliableSession", out label);
271 BindingTestAssertions.NetTcpBinding (
272 Context, doc, SecurityMode.None, true,
273 TransferMode.Buffered, label);
277 public virtual void BasicHttp_Operation ()
280 var doc = GetMetadata ("BasicHttp_Operation", out label);
282 BindingTestAssertions.TestOperation (doc, false, label);
286 public virtual void NetTcp_Operation ()
289 var doc = GetMetadata ("NetTcp_Operation", out label);
291 BindingTestAssertions.TestOperation (doc, true, label);