/// <summary>
 /// Checks the specified configuration manager.
 /// </summary>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <returns></returns>
 public override ProblemCollection Check(ServiceModelConfigurationManager configurationManager)
 {
     // Check for service endpoints
     foreach (ServiceElement serviceElement in configurationManager.GetServices())
     {
         foreach(ServiceEndpointElement endpointElement in serviceElement.Endpoints)
         {
             if(endpointElement.Binding.Equals(CustomBindingAttributeValue, StringComparison.InvariantCultureIgnoreCase))
             {
                 CheckRuleForCustomBinding(configurationManager.GetCustomBinding(endpointElement.BindingConfiguration));
             }
         }
     }
     // Check for client endponts
     ClientSection client = configurationManager.ServiceModelSection.Client;
     if(client != null)
     {
         foreach(ChannelEndpointElement clientEndpoint in client.Endpoints)
         {
             if (clientEndpoint.Binding.Equals(CustomBindingAttributeValue, StringComparison.InvariantCultureIgnoreCase))
             {
                 CheckRuleForCustomBinding(configurationManager.GetCustomBinding(clientEndpoint.BindingConfiguration));
             }
         }
     }
     return base.Problems;
 }
        public void UpdateCustomBindingTest()
        {
            ServiceModelConfigurationManager manager = LoadManager();

            manager.AddCustomBinding(new CustomBindingElement(Constants.ServiceBindingName));

            CustomBindingElement element = manager.GetCustomBinding(Constants.ServiceBindingName);

            element.Add(new SecurityElement());
            element.Add(new HttpTransportElement());
            manager.AddCustomBinding(element);

            CustomBindingElement updatedElement = manager.GetCustomBinding(Constants.ServiceBindingName);

            Assert.AreEqual(2, updatedElement.Count);
        }
        public void ClientBindingTest()
        {
            ServiceModelConfigurationManager manager = LoadManager();
            ClientSection        client          = manager.GetClient();
            CustomBindingElement binding         = manager.GetCustomBinding(client.Endpoints[0].BindingConfiguration);
            SecurityElement      securitySection = binding[typeof(SecurityElement)] as SecurityElement;

            Assert.IsNotNull(securitySection);
            Assert.AreEqual(AuthenticationMode.UserNameForSslNegotiated, securitySection.SecureConversationBootstrap.AuthenticationMode);
        }
        public void AddCustomBindingTest()
        {
            CustomBindingElement             element = new CustomBindingElement("newBasicBinding");
            ServiceModelConfigurationManager manager = LoadManager();

            manager.AddCustomBinding(element);

            CustomBindingElement addedElement = manager.GetCustomBinding("newBasicBinding");

            Assert.AreEqual(element.Name, addedElement.Name);
        }
        public void AddCustomBindingNewSectionTest()
        {
            // Remove any previous CustomBinding section
            ServiceModelConfigurationManager manager = LoadManager();

            manager.Configuration.Sections.Remove("customBinding");

            CustomBindingElement element = new CustomBindingElement("newBasicBinding");

            manager.AddCustomBinding(element);

            CustomBindingElement addedElement = manager.GetCustomBinding("newBasicBinding");

            Assert.AreEqual(element.Name, addedElement.Name);
        }