public void Simple()
    {
        GlobalFilters.Add <Target>((o, target) => target.Property != "Ignore");
        Assert.True(GlobalFilters.ShouldInclude(null, new Target()));
        Assert.False(GlobalFilters.ShouldInclude(null, null));
        Assert.True(GlobalFilters.ShouldInclude(null, new Target {
            Property = "Include"
        }));
        Assert.False(GlobalFilters.ShouldInclude(null, new Target {
            Property = "Ignore"
        }));

        GlobalFilters.Add <BaseTarget>((o, target) => target.Property != "Ignore");
        Assert.True(GlobalFilters.ShouldInclude(null, new ChildTarget()));
        Assert.True(GlobalFilters.ShouldInclude(null, new ChildTarget {
            Property = "Include"
        }));
        Assert.False(GlobalFilters.ShouldInclude(null, new ChildTarget {
            Property = "Ignore"
        }));

        GlobalFilters.Add <ITarget>((o, target) => target.Property != "Ignore");
        Assert.True(GlobalFilters.ShouldInclude(null, new ImplementationTarget()));
        Assert.True(GlobalFilters.ShouldInclude(null, new ImplementationTarget {
            Property = "Include"
        }));
        Assert.False(GlobalFilters.ShouldInclude(null, new ImplementationTarget {
            Property = "Ignore"
        }));

        Assert.True(GlobalFilters.ShouldInclude(null, new NonTarget {
            Property = "Foo"
        }));
    }
    static async Task <Connection <TReturn> > Range <TSource, TReturn>(
        IQueryable <TReturn> list,
        int skip,
        int take, int count,
        ResolveFieldContext <TSource> context,
        CancellationToken cancellation,
        bool reverse = false)
    {
        var page = list.Skip(skip).Take(take);

        IEnumerable <TReturn> result = await page
                                       .ToListAsync(cancellation)
                                       .ConfigureAwait(false);

        result = result.Where(item => GlobalFilters.ShouldInclude(context.UserContext, item));

        cancellation.ThrowIfCancellationRequested();
        return(Build(skip, take, count, reverse, result));
    }
    public async Task Simple()
    {
        var filters = new GlobalFilters();

        filters.Add <Target>((o, target) => target.Property != "Ignore");
        Assert.True(await filters.ShouldInclude(null, new Target()));
        Assert.False(await filters.ShouldInclude <object>(null, null));
        Assert.True(await filters.ShouldInclude(null, new Target {
            Property = "Include"
        }));
        Assert.False(await filters.ShouldInclude(null, new Target {
            Property = "Ignore"
        }));

        filters.Add <BaseTarget>((o, target) => target.Property != "Ignore");
        Assert.True(await filters.ShouldInclude(null, new ChildTarget()));
        Assert.True(await filters.ShouldInclude(null, new ChildTarget {
            Property = "Include"
        }));
        Assert.False(await filters.ShouldInclude(null, new ChildTarget {
            Property = "Ignore"
        }));

        filters.Add <ITarget>((o, target) => target.Property != "Ignore");
        Assert.True(await filters.ShouldInclude(null, new ImplementationTarget()));
        Assert.True(await filters.ShouldInclude(null, new ImplementationTarget {
            Property = "Include"
        }));
        Assert.False(await filters.ShouldInclude(null, new ImplementationTarget {
            Property = "Ignore"
        }));

        Assert.True(await filters.ShouldInclude(null, new NonTarget {
            Property = "Foo"
        }));
    }