本文整理汇总了C#中System.Web.Http.Services.DefaultServices.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# DefaultServices.Clear方法的具体用法?C# DefaultServices.Clear怎么用?C# DefaultServices.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Http.Services.DefaultServices
的用法示例。
在下文中一共展示了DefaultServices.Clear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetServices_ReturnsEmptyEnumerationWhenServiceListEmpty
public void GetServices_ReturnsEmptyEnumerationWhenServiceListEmpty()
{
// Arrange
var config = new HttpConfiguration();
var defaultServices = new DefaultServices(config);
defaultServices.Clear(typeof(IFilterProvider));
// Act
IEnumerable<object> services = defaultServices.GetServices(typeof(IFilterProvider));
// Assert
Assert.Empty(services);
}
示例2: GetService_ReturnsNullWhenServiceListEmpty
public void GetService_ReturnsNullWhenServiceListEmpty()
{
// Arrange
var config = new HttpConfiguration();
var defaultServices = new DefaultServices(config);
defaultServices.Clear(typeof(IActionValueBinder));
// Act
object service = defaultServices.GetService(typeof(IActionValueBinder));
// Assert
Assert.Null(service);
}
示例3: Clear_RemovesAllServices
public void Clear_RemovesAllServices()
{
// Arrange
var config = new HttpConfiguration();
var defaultServices = new DefaultServices(config);
Assert.NotEmpty(defaultServices.GetServices(typeof(IFilterProvider)));
// Act
defaultServices.Clear(typeof(IFilterProvider));
// Assert
Assert.Empty(defaultServices.GetServices(typeof(IFilterProvider)));
}
示例4: FindIndex_EmptyServiceListAlwaysReturnsFailure
public void FindIndex_EmptyServiceListAlwaysReturnsFailure()
{
// Arrange
var config = new HttpConfiguration();
var defaultServices = new DefaultServices(config);
defaultServices.Clear(typeof(IFilterProvider));
// Act
int index = defaultServices.FindIndex(typeof(IFilterProvider), _ => true);
// Assert
Assert.Equal(-1, index);
}
示例5: Clear_GuardClauses
public void Clear_GuardClauses()
{
// Arrange
var config = new HttpConfiguration();
var defaultServices = new DefaultServices(config);
// Act & assert
Assert.ThrowsArgumentNull(() => defaultServices.Clear(serviceType: null), "serviceType");
Assert.ThrowsArgument(
() => defaultServices.Clear(typeof(object)),
"serviceType",
"The service type Object is not supported.");
}