Ejemplo n.º 1
0
        public void GetFilters_ReturnsEmptyCollection_ForNonQueryableActions(string actionName)
        {
            HttpConfiguration        config = new HttpConfiguration();
            HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(config, "FilterProviderTest", typeof(FilterProviderTestController));
            HttpActionDescriptor     actionDescriptor     = new ReflectedHttpActionDescriptor(controllerDescriptor, typeof(FilterProviderTestController).GetMethod(actionName));

            FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute()).GetFilters(config, actionDescriptor).ToArray();

            Assert.Empty(filters);
        }
        public void GetFilters_ReturnsEmptyCollection_ForNonQueryableActions(string actionName)
        {
            HttpConfiguration config = new HttpConfiguration();
            HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(config, "FilterProviderTest", typeof(FilterProviderTestController));
            HttpActionDescriptor actionDescriptor = new ReflectedHttpActionDescriptor(controllerDescriptor, typeof(FilterProviderTestController).GetMethod(actionName));

            FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute()).GetFilters(config, actionDescriptor).ToArray();

            Assert.Empty(filters);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="TableFilterProvider"/> using the provided <see cref="QueryableAttribute"/>
        /// implementation for executing the query. 
        /// </summary>
        public TableFilterProvider(IActionFilter queryFilter)
        {
            if (queryFilter == null)
            {
                throw new ArgumentNullException("queryFilter");
            }

            this.queryFilter = new QueryableAttribute() { PageSize = TableUtils.PageSize };
            this.queryFilterProvider = new QueryFilterProvider(queryFilter);
            this.tableFilter = new FilterInfo(new TableQueryFilter(), FilterScope.Global);
        }
        public void GetFilters_ReturnsQueryableFilter_ForQueryableActions(string actionName)
        {
            HttpConfiguration config = new HttpConfiguration();
            HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(config, "FilterProviderTest", typeof(FilterProviderTestController));
            HttpActionDescriptor actionDescriptor = new ReflectedHttpActionDescriptor(controllerDescriptor, typeof(FilterProviderTestController).GetMethod(actionName));

            FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute()).GetFilters(config, actionDescriptor).ToArray();

            Assert.Equal(1, filters.Length);
            Assert.Equal(FilterScope.Global, filters[0].Scope);
            EnableQueryAttribute filter = Assert.IsType<EnableQueryAttribute>(filters[0].Instance);
        }
Ejemplo n.º 5
0
        public void GetFilters_ReturnsQueryableFilter_ForQueryableActions(string actionName)
        {
            HttpConfiguration        config = new HttpConfiguration();
            HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(config, "FilterProviderTest", typeof(FilterProviderTestController));
            HttpActionDescriptor     actionDescriptor     = new ReflectedHttpActionDescriptor(controllerDescriptor, typeof(FilterProviderTestController).GetMethod(actionName));

            FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute()).GetFilters(config, actionDescriptor).ToArray();

            Assert.Equal(1, filters.Length);
            Assert.Equal(FilterScope.Global, filters[0].Scope);
            EnableQueryAttribute filter = Assert.IsType <EnableQueryAttribute>(filters[0].Instance);
        }
        public void GetFilters_ReturnsEmptyCollections_ForActionsWithQueryableAttributeApplied(
            string actionName, 
            Type controllerType)
        {
            // Arrange
            HttpConfiguration config = new HttpConfiguration();
            string controllerName = controllerType.Name.Replace("Controller","");
            HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(
                config, 
                controllerName,
                controllerType);

            HttpActionDescriptor actionDescriptor = new ReflectedHttpActionDescriptor(
                controllerDescriptor, 
                controllerType.GetMethod(actionName));

            // Act
            FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute(), skipQueryableAttribute: true)
                .GetFilters(config, actionDescriptor).ToArray();

            // Assert
            Assert.Empty(filters);
        }
Ejemplo n.º 7
0
        public void GetFilters_ReturnsEmptyCollections_ForActionsWithQueryableAttributeApplied(
            string actionName,
            Type controllerType)
        {
            // Arrange
            HttpConfiguration        config               = new HttpConfiguration();
            string                   controllerName       = controllerType.Name.Replace("Controller", "");
            HttpControllerDescriptor controllerDescriptor = new HttpControllerDescriptor(
                config,
                controllerName,
                controllerType);

            HttpActionDescriptor actionDescriptor = new ReflectedHttpActionDescriptor(
                controllerDescriptor,
                controllerType.GetMethod(actionName));

            // Act
            FilterInfo[] filters = new QueryFilterProvider(new EnableQueryAttribute(), skipQueryableAttribute: true)
                                   .GetFilters(config, actionDescriptor).ToArray();

            // Assert
            Assert.Empty(filters);
        }
Ejemplo n.º 8
0
 public void IsIQueryable_ReturnsWhetherTypeIsIQueryable(Type type, bool isIQueryable)
 {
     Assert.Equal(isIQueryable, QueryFilterProvider.IsIQueryable(type));
 }