コード例 #1
0
        public void FilterConvention_Should_Fail_When_FieldHandlerIsNotRegistered()
        {
            // arrange
            var provider = new QueryableFilterProvider(
                descriptor =>
            {
                descriptor.AddFieldHandler <QueryableStringEqualsHandler>();
            });

            var convention = new FilterConvention(
                descriptor =>
            {
                descriptor.Operation(DefaultOperations.Equals).Name("eq");
                descriptor.BindRuntimeType <string, TestOperationFilterType>();
                descriptor.Provider(provider);
            });

            var type = new FooFilterType();

            //act
            SchemaException?error =
                Assert.Throws <SchemaException>(() => CreateSchemaWith(type, convention));

            Assert.Single(error.Errors);
            error.Errors[0].Message.MatchSnapshot();
        }
コード例 #2
0
        public void SortConvention_Should_Fail_When_FieldHandlerIsNotRegistered()
        {
            // arrange
            var provider = new QueryableSortProvider(
                descriptor =>
            {
                descriptor.AddOperationHandler <QueryableAscendingSortOperationHandler>();
            });

            var convention = new SortConvention(
                descriptor =>
            {
                descriptor.Operation(DefaultSortOperations.Ascending).Name("asc");
                descriptor.BindRuntimeType <string, TestEnumType>();
                descriptor.Provider(provider);
            });

            var type = new FooSortType();

            //act
            SchemaException?error =
                Assert.Throws <SchemaException>(() => CreateSchemaWith(type, convention));

            Assert.Single(error.Errors);
            error.Errors[0].Message.MatchSnapshot();
        }
コード例 #3
0
        public void FilterConvention_Should_Fail_When_NoMatchingBindingWasFound()
        {
            // arrange
            var provider = new QueryableFilterProvider(
                descriptor =>
            {
                descriptor.AddFieldHandler <QueryableStringEqualsHandler>();
                descriptor.AddFieldHandler <QueryableDefaultFieldHandler>();
            });

            var convention = new FilterConvention(
                descriptor =>
            {
                descriptor.Operation(DefaultOperations.Equals).Name("eq");
                descriptor.Provider(provider);
            });

            var type = new FooFilterType();

            //act
            SchemaException?error =
                Assert.Throws <SchemaException>(() => CreateSchemaWith(type, convention));

            Assert.Single(error.Errors);
#if NETCOREAPP2_1
            error.Errors[0].Message.MatchSnapshot(new SnapshotNameExtension("NETCOREAPP2_1"));
#else
            error.Errors[0].Message.MatchSnapshot();
#endif
        }
コード例 #4
0
        public void FilterConvention_Should_Fail_When_NoProviderWasRegistered()
        {
            // arrange
            var convention = new FilterConvention(
                descriptor =>
            {
                descriptor.Operation(DefaultFilterOperations.Equals).Name("eq");
                descriptor.BindRuntimeType <string, TestOperationFilterInputType>();
            });

            var type = new FooFilterInput();

            //act
            SchemaException?error =
                Assert.Throws <SchemaException>(() => CreateSchemaWith(type, convention));

            Assert.Single(error.Errors);
            error.Errors[0].Message.MatchSnapshot();
        }