本文整理汇总了C#中System.Web.Http.SelfHost.HttpSelfHostConfiguration.ConfigureBinding方法的典型用法代码示例。如果您正苦于以下问题:C# HttpSelfHostConfiguration.ConfigureBinding方法的具体用法?C# HttpSelfHostConfiguration.ConfigureBinding怎么用?C# HttpSelfHostConfiguration.ConfigureBinding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.SelfHost.HttpSelfHostConfiguration
的用法示例。
在下文中一共展示了HttpSelfHostConfiguration.ConfigureBinding方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithX509CertificateValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
X509CertificateValidator = new Mock<X509CertificateValidator>().Object
};
config.ClientCredentialType = clientCredentialType;
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
}
示例2: HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding
public void HttpSelfHostConfiguration_UserNamePasswordValidator_PropagatesToBinding(string address, HttpBindingSecurityMode mode)
{
// Arrange
HttpBinding binding = new HttpBinding();
UserNamePasswordValidator validator = new Mock<UserNamePasswordValidator>().Object;
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
UserNamePasswordValidator = validator
};
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
// Assert
Assert.NotNull(parameters);
ServiceCredentials serviceCredentials = parameters.Find<ServiceCredentials>();
Assert.NotNull(serviceCredentials);
Assert.Equal(HttpClientCredentialType.Basic, binding.Security.Transport.ClientCredentialType);
Assert.Equal(mode, binding.Security.Mode);
}
示例3: HttpSelfHostConfiguration_CorrectClientCredentialType_WithUsernamePasswordValidator_Works
public void HttpSelfHostConfiguration_CorrectClientCredentialType_WithUsernamePasswordValidator_Works(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
UserNamePasswordValidator = new CustomUsernamePasswordValidator()
};
config.ClientCredentialType = clientCredentialType;
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
}
示例4: HttpSelfHostConfiguration_WrongClientCredentialType_WithX509CertificateValidator_Throws
public void HttpSelfHostConfiguration_WrongClientCredentialType_WithX509CertificateValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
X509CertificateValidator = new Mock<X509CertificateValidator>().Object
};
config.ClientCredentialType = clientCredentialType;
Assert.Throws<InvalidOperationException>(() =>
{
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
});
}
示例5: HttpSelfHostConfiguration_WrongClientCredentialType_WithUsernamePasswordValidator_Throws
public void HttpSelfHostConfiguration_WrongClientCredentialType_WithUsernamePasswordValidator_Throws(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
UserNamePasswordValidator = new CustomUsernamePasswordValidator()
};
config.ClientCredentialType = clientCredentialType;
Assert.Throws<InvalidOperationException>(() =>
{
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
});
}
示例6: HttpSelfHostConfiguration_ClientCredentialType_PropagatesToHttpBinding
public void HttpSelfHostConfiguration_ClientCredentialType_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode, HttpClientCredentialType clientCredentialType)
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
ClientCredentialType = clientCredentialType
};
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
Assert.Equal(clientCredentialType, binding.Security.Transport.ClientCredentialType);
Assert.Equal(mode, binding.Security.Mode);
}
示例7: HttpSelfHostConfiguration_Settings_PropagateToBinding
public void HttpSelfHostConfiguration_Settings_PropagateToBinding()
{
// Arrange
HttpBinding binding = new HttpBinding();
binding.ConfigureTransportBindingElement = ConfigureTransportBindingElement;
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost")
{
MaxBufferSize = 10,
MaxReceivedMessageSize = 11,
ReceiveTimeout = new TimeSpan(1, 0, 0),
SendTimeout = new TimeSpan(1, 0, 0),
TransferMode = TransferMode.StreamedResponse,
HostNameComparisonMode = HostNameComparisonMode.WeakWildcard
};
// Act
config.ConfigureBinding(binding);
// Assert
Assert.Equal(10, binding.MaxBufferSize);
Assert.Equal(11, binding.MaxReceivedMessageSize);
Assert.Equal(new TimeSpan(1, 0, 0), binding.ReceiveTimeout);
Assert.Equal(new TimeSpan(1, 0, 0), binding.SendTimeout);
Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode);
Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode);
Assert.Equal(Net.AuthenticationSchemes.Ntlm, binding.CreateBindingElements().Find<HttpTransportBindingElement>().AuthenticationScheme);
}
示例8: HttpSelfHostConfiguration_UseWindowsAuth_PropagatesToHttpBinding
public void HttpSelfHostConfiguration_UseWindowsAuth_PropagatesToHttpBinding(string address, HttpBindingSecurityMode mode)
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration(address)
{
UseWindowsAuthentication = true
};
// Act
BindingParameterCollection parameters = config.ConfigureBinding(binding);
// Assert
Assert.NotNull(parameters);
ServiceCredentials serviceCredentials = parameters.Find<ServiceCredentials>();
Assert.NotNull(serviceCredentials);
Assert.Equal(HttpClientCredentialType.Windows, binding.Security.Transport.ClientCredentialType);
Assert.Equal(mode, binding.Security.Mode);
}
示例9: HttpSelfHostConfiguration_Settings_PropagateToBinding
public void HttpSelfHostConfiguration_Settings_PropagateToBinding()
{
// Arrange
HttpBinding binding = new HttpBinding();
HttpSelfHostConfiguration config = new HttpSelfHostConfiguration("http://localhost")
{
MaxBufferSize = 10,
MaxReceivedMessageSize = 11,
TransferMode = TransferMode.StreamedResponse,
HostNameComparisonMode = HostNameComparisonMode.WeakWildcard
};
// Act
config.ConfigureBinding(binding);
// Assert
Assert.Equal(10, binding.MaxBufferSize);
Assert.Equal(11, binding.MaxReceivedMessageSize);
Assert.Equal(TransferMode.StreamedResponse, binding.TransferMode);
Assert.Equal(HostNameComparisonMode.WeakWildcard, binding.HostNameComparisonMode);
}