public void HttpBinding_Throws_When_No_Binding_Section() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.EmptyConfigurationTest.config", () => { ExceptionAssert.Throws <ConfigurationErrorsException>(null, () => new HttpBinding("configuredBinding")); }); }
public void HttpBinding_Correctly_Configured_With_Empty_Name_Configuration() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBindingTest.config", () => { HttpBinding binding = new HttpBinding(""); Assert.AreEqual(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode, "Binding.HostNameComparisonMode should have been HostNameComparisonMode.WeakWildcard."); }); }
public void HttpBinding_Throws_With_Unknown_ConfigurationName_Parameter() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBindingTest.config", () => { ExceptionAssert.Throws <ConfigurationErrorsException>( null, () => { new HttpBinding("noSuchConfiguredBinding"); }); }); }
public void Behavior_Configured_Behavior_From_Host() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBehaviorWithServiceTest.config", () => { HttpBehavior[] behaviors = GetBehaviorsFromServiceHost(typeof(CustomerService), new Uri("http://somehost")); Assert.AreEqual(1, behaviors.Length, "Expected 1 behavior"); HttpBehavior behavior = behaviors[0]; Assert.IsFalse(behavior.HelpEnabled, "HelpEnabled wrong"); Assert.AreEqual(TrailingSlashMode.Ignore, behavior.TrailingSlashMode, "TrailingSlashMode wrong"); }); }
public void HttpMessageBinding_Throws_With_Unknown_ConfigurationName_Parameter() { ConfigAssert.Execute("BindingConfigurationTest.config", () => { ExceptionAssert.Throws( typeof(ConfigurationErrorsException), "The HttpMessageBinding should have thrown since the configurationName was unknown.", () => { new HttpMessageBinding("noSuchConfiguredBinding"); }); }); }
public void HttpMessageBinding_Throws_When_No_Binding_Section() { ConfigAssert.Execute("NoBindingConfigurationTest.config", () => { ExceptionAssert.Throws( typeof(ConfigurationErrorsException), "The HttpMessageBinding should have thrown since there is no binding section in the config file.", () => { new HttpMessageBinding("configuredBinding"); }); }); }
public void HttpBinding_Correctly_Configured_With_Name_Configuration() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBindingTest.config", () => { HttpBinding binding = new HttpBinding("configuredBinding"); Assert.AreEqual(HostNameComparisonMode.Exact, binding.HostNameComparisonMode, "Binding.HostNameComparisonMode should have been HostNameComparisonMode.Exact."); Assert.AreEqual(500, binding.MaxBufferPoolSize, "Binding.MaxBufferPoolSize should have been 500."); Assert.AreEqual(100, binding.MaxReceivedMessageSize, "Binding.MaxReceivedMessageSize should have been 100."); Assert.AreEqual(200, binding.MaxBufferSize, "Binding.MaxBufferSize should have been 200."); Assert.AreEqual(TransferMode.StreamedResponse, binding.TransferMode, "Binding.TransferMode should have been TransferMode.StreamedResponse."); Assert.AreEqual(HttpBindingSecurityMode.Transport, binding.Security.Mode, "Binding.Security.Mode should have been HttpBindingSecurityMode.Transport."); Assert.AreEqual("someConfigRealm", binding.Security.Transport.Realm, "Binding.Security.Transport.Realm should have been 'someConfigRealm'."); Assert.AreEqual(HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType, "Binding.Security.Transport.ClientCredentialType should have been HttpClientCredentialType.Basic."); Assert.AreEqual(HttpProxyCredentialType.Ntlm, binding.Security.Transport.ProxyCredentialType, "Binding.Security.Transport.ProxyCredentialType should have been HttpProxyCredentialType.Ntlm."); Assert.AreEqual(PolicyEnforcement.WhenSupported, binding.Security.Transport.ExtendedProtectionPolicy.PolicyEnforcement, "Binding.Transport.ExtendedProtectionPolicy.PolicyEnforcement should have been PolicyEnforcement.WhenSupported"); }); }
public void Endpoint_Configured_Endpoint_From_ServiceHost() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpEndpointWithServiceTest.config", () => { HttpEndpoint[] endPoints = GetEndpointsFromServiceHost(typeof(CustomerService), new Uri("http://somehost")); Assert.IsTrue(endPoints.Length > 0, "No HttpEndpoints"); HttpEndpoint endPoint = endPoints[0]; Assert.AreEqual("HttpBinding_CustomerService", endPoint.Name, "Should have had this name"); Assert.AreEqual(HostNameComparisonMode.Exact, endPoint.HostNameComparisonMode, "HostNameComparisonMode was not set"); Assert.IsFalse(endPoint.HelpEnabled, "HelpEnabled wrong"); Assert.AreEqual(TransferMode.Streamed, endPoint.TransferMode, "TransferMode wrong"); Assert.AreEqual(HostNameComparisonMode.Exact, endPoint.HostNameComparisonMode, "HostNameComparisonMode wrong"); Assert.AreEqual(1, endPoint.MaxBufferPoolSize, "MaxBufferPoolSize wrong"); Assert.AreEqual(2, endPoint.MaxBufferSize, "MaxBufferSize wrong"); Assert.AreEqual(3, endPoint.MaxReceivedMessageSize, "MaxReceivedMessageSize wrong"); }); }
public void Behavior_Element_From_Config_Directly() { ConfigAssert.Execute("Microsoft.ApplicationServer.Http.CIT.Unit.ConfiguredHttpBehaviorTest.config", () => { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); ServiceModelSectionGroup section = ServiceModelSectionGroup.GetSectionGroup(config); BehaviorsSection behaviors = section.Behaviors; Assert.AreEqual(2, behaviors.EndpointBehaviors.Count, "Wrong number of behaviors"); HttpBehaviorElement namedElement = behaviors.EndpointBehaviors[0].FirstOrDefault() as HttpBehaviorElement; Assert.AreEqual(TrailingSlashMode.Ignore, namedElement.TrailingSlashMode, "TrailingSlash wrong"); Assert.IsFalse(namedElement.HelpEnabled, "HelpEnabled wrong"); HttpBehaviorElement defaultElement = behaviors.EndpointBehaviors[1].FirstOrDefault() as HttpBehaviorElement; Assert.AreEqual(TrailingSlashMode.Ignore, defaultElement.TrailingSlashMode, "TrailingSlash wrong"); Assert.IsFalse(defaultElement.HelpEnabled, "HelpEnabled wrong"); }); }