1 #if !MOBILE && !MONOMAC
3 using System.ServiceModel.Configuration;
5 using System.ServiceModel;
7 using System.Configuration;
9 namespace MonoTests.System.ServiceModel.Configuration
12 public class WebHttpBindingElementTest
14 class Poker : WebHttpBindingElement
16 public Type GetBindingElementType ()
18 return BindingElementType;
23 public void BindingElementType ()
25 Poker poker = new Poker ();
26 Assert.AreEqual (typeof (WebHttpBinding), poker.GetBindingElementType (), "BindingElementType");
30 public void ApplyConfiguration ()
32 WebHttpBinding b = CreateBindingFromConfig ();
34 Assert.AreEqual (true, b.AllowCookies, "#1");
35 Assert.AreEqual (true, b.BypassProxyOnLocal, "#2");
36 Assert.AreEqual (HostNameComparisonMode.Exact, b.HostNameComparisonMode, "#3");
37 Assert.AreEqual (262144, b.MaxBufferPoolSize, "#4");
38 Assert.AreEqual (32768, b.MaxBufferSize, "#5");
39 Assert.AreEqual (16384, b.MaxReceivedMessageSize, "#6");
40 Assert.AreEqual ("proxy", b.ProxyAddress.ToString (), "#7");
41 Assert.AreEqual (Encoding.Unicode, b.WriteEncoding, "#8");
42 Assert.AreEqual (TransferMode.Streamed, b.TransferMode, "#9");
46 public void Security ()
48 WebHttpBinding b = CreateBindingFromConfig ();
49 Assert.AreEqual (WebHttpSecurityMode.TransportCredentialOnly, b.Security.Mode, "#1");
50 Assert.AreEqual (HttpClientCredentialType.Basic, b.Security.Transport.ClientCredentialType, "#2");
54 private WebHttpBinding CreateBindingFromConfig ()
56 ServiceModelSectionGroup config = (ServiceModelSectionGroup) ConfigurationManager.OpenExeConfiguration ("Test/config/webHttpBinding").GetSectionGroup ("system.serviceModel");
57 WebHttpBindingCollectionElement collectionElement = (WebHttpBindingCollectionElement) config.Bindings ["webHttpBinding"];
59 WebHttpBindingElement el = collectionElement.Bindings ["WebHttpBinding1_Service"];
61 WebHttpBinding b = new WebHttpBinding ();
62 el.ApplyConfiguration (b);