本文整理汇总了C#中Mock.GetFilterPipeline方法的典型用法代码示例。如果您正苦于以下问题:C# Mock.GetFilterPipeline方法的具体用法?C# Mock.GetFilterPipeline怎么用?C# Mock.GetFilterPipeline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mock
的用法示例。
在下文中一共展示了Mock.GetFilterPipeline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFilters_RemovesDuplicateUniqueFiltersKeepingMostSpecificScope
public void GetFilters_RemovesDuplicateUniqueFiltersKeepingMostSpecificScope()
{
// Arrange
HttpActionDescriptor actionDescriptorMock = new Mock<HttpActionDescriptor>() { CallBase = true }.Object;
actionDescriptorMock.Configuration = _configurationInstance;
var multiActionFilter = new FilterInfo(new TestMultiFilter(), FilterScope.Action);
var multiGlobalFilter = new FilterInfo(new TestMultiFilter(), FilterScope.Global);
var uniqueControllerFilter = new FilterInfo(new TestUniqueFilter(), FilterScope.Controller);
var uniqueActionFilter = new FilterInfo(new TestUniqueFilter(), FilterScope.Action);
Mock<DefaultServices> servicesMock = BuildFilterProvidingServicesMock(
_configurationInstance, actionDescriptorMock,
multiActionFilter, multiGlobalFilter, uniqueControllerFilter, uniqueActionFilter);
_configurationInstance.Services = servicesMock.Object;
// Act
var result = actionDescriptorMock.GetFilterPipeline().ToArray();
// Assert
Assert.Equal(new[] { multiGlobalFilter, multiActionFilter, uniqueActionFilter }, result);
}
示例2: GetFilters_UsesFilterProvidersToGetFilters
public void GetFilters_UsesFilterProvidersToGetFilters()
{
// Arrange
Mock<DefaultServices> servicesMock = new Mock<DefaultServices> { CallBase = true };
Mock<IFilterProvider> filterProviderMock = new Mock<IFilterProvider>();
servicesMock.Setup(r => r.GetServices(typeof(IFilterProvider))).Returns(new[] { filterProviderMock.Object });
_configurationInstance.Services = servicesMock.Object;
HttpActionDescriptor actionDescriptorMock = new Mock<HttpActionDescriptor>() { CallBase = true }.Object;
actionDescriptorMock.Configuration = _configurationInstance;
// Act
actionDescriptorMock.GetFilterPipeline().ToList();
// Assert
filterProviderMock.Verify(fp => fp.GetFilters(_configurationInstance, actionDescriptorMock));
}
示例3: GetFilters_OrdersFilters
public void GetFilters_OrdersFilters()
{
// Arrange
HttpActionDescriptor actionDescriptorMock = new Mock<HttpActionDescriptor>() { CallBase = true }.Object;
actionDescriptorMock.Configuration = _configurationInstance;
var globalFilter = new FilterInfo(new TestMultiFilter(), FilterScope.Global);
var actionFilter = new FilterInfo(new TestMultiFilter(), FilterScope.Action);
var controllerFilter = new FilterInfo(new TestMultiFilter(), FilterScope.Controller);
Mock<DefaultServices> servicesMock = BuildFilterProvidingServicesMock(_configurationInstance, actionDescriptorMock, globalFilter, actionFilter, controllerFilter);
_configurationInstance.Services = servicesMock.Object;
// Act
var result = actionDescriptorMock.GetFilterPipeline().ToArray();
// Assert
Assert.Equal(new[] { globalFilter, controllerFilter, actionFilter }, result);
}
示例4: GetFilters_QueriesFilterProvidersFromServices
public void GetFilters_QueriesFilterProvidersFromServices()
{
// Arrange
Mock<DefaultServices> servicesMock = new Mock<DefaultServices> { CallBase = true };
Mock<IFilterProvider> filterProviderMock = new Mock<IFilterProvider>();
servicesMock.Setup(r => r.GetServices(typeof(IFilterProvider))).Returns(new object[] { filterProviderMock.Object }).Verifiable();
_configurationInstance.Services = servicesMock.Object;
HttpActionDescriptor actionDescriptorMock = new Mock<HttpActionDescriptor>() { CallBase = true }.Object;
actionDescriptorMock.Configuration = _configurationInstance;
// Act
actionDescriptorMock.GetFilterPipeline();
// Assert
servicesMock.Verify();
}