public void HttpTransportSecurityElement_InitializeFrom()
        {
            HttpTransportSecurityElement element = new HttpTransportSecurityElement()
            {
                ClientCredentialType = HttpClientCredentialType.Basic,
                ProxyCredentialType  = HttpProxyCredentialType.Basic,
                Realm = "MyRealm"
            };
            HttpTransportSecurity security = new HttpTransportSecurity();

            // first initialize the transport security
            element.ApplyConfiguration(security);

            Assert.AreEqual(element.ClientCredentialType, security.ClientCredentialType, "ClientCredentialType failed");
            Assert.AreEqual(element.ProxyCredentialType, security.ProxyCredentialType, "ProxyCredentialType failed");
            Assert.AreEqual(element.Realm, security.Realm, "Realm failed");
            Assert.IsNotNull(security.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed");

            // now initialize a new instance from the security
            HttpTransportSecurityElement element2 = new HttpTransportSecurityElement();

            element2.InitializeFrom(security);

            Assert.AreEqual(element.ClientCredentialType, element2.ClientCredentialType, "ClientCredentialType failed");
            Assert.AreEqual(element.ProxyCredentialType, element2.ProxyCredentialType, "ProxyCredentialType failed");
            Assert.AreEqual(element.Realm, element2.Realm, "Realm failed");
            Assert.IsNotNull(element2.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed");
        }
        internal static void ApplyConfiguration(this HttpTransportSecurityElement httpTransportSecurityElement, HttpTransportSecurity httpTransportSecurity)
        {
            Fx.Assert(httpTransportSecurityElement != null, "httpTransportSecurityElement cannot be null");
            Fx.Assert(httpTransportSecurity != null, "httpTransportSecurity cannot be null");

            httpTransportSecurity.ClientCredentialType = httpTransportSecurityElement.ClientCredentialType;
            httpTransportSecurity.ProxyCredentialType  = httpTransportSecurityElement.ProxyCredentialType;
            httpTransportSecurity.Realm = httpTransportSecurityElement.Realm;
            httpTransportSecurity.ExtendedProtectionPolicy = ChannelBindingUtility.BuildPolicy(httpTransportSecurityElement.ExtendedProtectionPolicy);
        }
        internal static void InitializeFrom(this HttpTransportSecurityElement httpTransportSecurityElement, HttpTransportSecurity httpTransportSecurity)
        {
            Fx.Assert(httpTransportSecurityElement != null, "httpTransportSecurityElement cannot be null");
            Fx.Assert(httpTransportSecurity != null, "httpTransportSecurity cannot be null");

            ConfigurationElementProxy proxy = new ConfigurationElementProxy(httpTransportSecurityElement);

            proxy.SetPropertyValueIfNotDefaultValue <HttpClientCredentialType>(ConfigurationStrings.ClientCredentialType, httpTransportSecurity.ClientCredentialType);
            proxy.SetPropertyValueIfNotDefaultValue <HttpProxyCredentialType>(ConfigurationStrings.ProxyCredentialType, httpTransportSecurity.ProxyCredentialType);
            proxy.SetPropertyValueIfNotDefaultValue <string>(ConfigurationStrings.Realm, httpTransportSecurity.Realm);

            ChannelBindingUtility.InitializeFrom(httpTransportSecurity.ExtendedProtectionPolicy, httpTransportSecurityElement.ExtendedProtectionPolicy);
        }
        public void HttpTransportSecurityElement_ApplyConfiguration()
        {
            HttpTransportSecurityElement element = new HttpTransportSecurityElement()
            {
                ClientCredentialType = HttpClientCredentialType.Basic,
                ProxyCredentialType  = HttpProxyCredentialType.Basic,
                Realm = "MyRealm"
            };
            HttpTransportSecurity security = new HttpTransportSecurity();

            element.ApplyConfiguration(security);

            Assert.AreEqual(element.ClientCredentialType, security.ClientCredentialType, "ClientCredentialType failed");
            Assert.AreEqual(element.ProxyCredentialType, security.ProxyCredentialType, "ProxyCredentialType failed");
            Assert.AreEqual(element.Realm, security.Realm, "Realm failed");
            Assert.IsNotNull(security.ExtendedProtectionPolicy, "ExtendedProtectionPolicy failed");
        }