public void Create_ShortNotGreaterThan_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ barShort: { ngt: 12 }}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterInput()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { BarShort = 11 }; Assert.True(func(a)); var b = new Foo { BarShort = 12 }; Assert.True(func(b)); var c = new Foo { BarShort = 13 }; Assert.False(func(c)); }
public void Create_NullableShortIn_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ barShort: { in: [13, 14] }}"); ExecutorBuilder?tester = CreateProviderTester(new FooNullableFilterInput()); // act Func <FooNullable, bool>?func = tester.Build <FooNullable>(value); // assert var a = new FooNullable { BarShort = 13 }; Assert.True(func(a)); var b = new FooNullable { BarShort = 12 }; Assert.False(func(b)); var c = new FooNullable { BarShort = null }; Assert.False(func(c)); }
public void Create_NonNullOnNullable_Attributes() { // arrange IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ nonNullOnNullable: { eq: THIRD }}"); ExecutorBuilder?tester = CreateProviderTester(new FilterInputType <AttributeTest>()); // act Func <AttributeTest, bool>?func = tester.Build <AttributeTest>(value); // assert var a = new AttributeTest { NonNullOnNullable = TestEnum.Third }; Assert.True(func(a)); var b = new AttributeTest { NonNullOnNullable = TestEnum.First }; Assert.False(func(b)); var c = new AttributeTest { NonNullOnNullable = null }; Assert.False(func(c)); }
public void Create_ObjectNullableEnumIn_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { barEnum: { in: [BAZ, QUX] }}}"); ExecutorBuilder?tester = CreateProviderTester(new BarNullableFilterType()); // act Func <BarNullable, bool>?func = tester.Build <BarNullable>(value); // assert var a = new BarNullable { Foo = new FooNullable { BarEnum = BarEnum.BAZ } }; Assert.True(func(a)); var b = new BarNullable { Foo = new FooNullable { BarEnum = BarEnum.BAR } }; Assert.False(func(b)); var c = new BarNullable { Foo = new FooNullable { BarEnum = null } }; Assert.False(func(c)); }
public void Create_ObjectNullableShortEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { barShort: { eq: 12 }}}"); ExecutorBuilder?tester = CreateProviderTester(new BarNullableFilterInput()); // act Func <BarNullable, bool>?func = tester.Build <BarNullable>(value); // assert var a = new BarNullable { Foo = new FooNullable { BarShort = 12 } }; Assert.True(func(a)); var b = new BarNullable { Foo = new FooNullable { BarShort = 13 } }; Assert.False(func(b)); var c = new BarNullable { Foo = new FooNullable { BarShort = null } }; Assert.False(func(c)); }
public void Create_NullableBooleanNotEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: { eq: false }}"); ExecutorBuilder?tester = CreateProviderTester(new FooNullableFilterType()); // act Func <FooNullable, bool>?func = tester.Build <FooNullable>(value); // assert var a = new FooNullable { Bar = false }; Assert.True(func(a)); var b = new FooNullable { Bar = true }; Assert.False(func(b)); var c = new FooNullable { Bar = null }; Assert.False(func(c)); }
public void Create_ArrayAnyStringEqual_Expression() { // arrange IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: {any: true}}"); ExecutorBuilder?tester = CreateProviderTester(new FooSimpleFilterInput()); // act Func <FooSimple, bool> func = tester.Build <FooSimple>(value); // assert var a = new FooSimple { Bar = new[] { "c", "d", "a" } }; Assert.True(func(a)); var b = new FooSimple { Bar = new string[0] }; Assert.False(func(b)); var c = new FooSimple { Bar = null }; Assert.False(func(c)); }
public void Create_ArraySomeStringEqualWithNull_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: {some: { eq: \"a\" }}}"); ExecutorBuilder?tester = CreateProviderTester(new FooSimpleFilterType()); // act Func <FooSimple, bool>?func = tester.Build <FooSimple>(value); // assert var a = new FooSimple { Bar = new[] { "c", null, "a" } }; Assert.True(func(a)); var b = new FooSimple { Bar = new[] { "c", null, "b" } }; Assert.False(func(b)); var c = new FooSimple { Bar = null }; Assert.False(func(c)); }
public void Create_MethodSimple_Expression() { // arrange IValueNode? value = Syntax.ParseValueLiteral("{ simple: { eq:\"a\" }}"); ExecutorBuilder?tester = CreateProviderTester( new FooFilterType(), new FilterConvention( x => { x.Operation(155).Name("simple"); x.Operation(156).Name("complex"); x.AddDefaults(); x.Provider( new QueryableFilterProvider( p => p.AddFieldHandler <QueryableSimpleMethodTest>() .AddFieldHandler <QueryableComplexMethodTest>() .AddDefaultFieldHandlers())); })); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { Bar = "a" }; Assert.True(func(a)); var b = new Foo { Bar = "b" }; Assert.False(func(b)); }
public void Create_ScalarArrayAnyStringEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { scalarArray: {any: true}}}"); ExecutorBuilder?tester = CreateProviderTester(new BarFilterInput()); // act Func <Bar, bool>?func = tester.Build <Bar>(value); // assert var a = new Bar { Foo = new Foo { ScalarArray = new[] { "c", "d", "a" } } }; Assert.True(func(a)); var b = new Bar { Foo = new Foo { ScalarArray = new string[0] } }; Assert.False(func(b)); var c = new Bar { Foo = new Foo { ScalarArray = null } }; Assert.False(func(c)); }
public void Create_ObjectEnumEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { barEnum: { eq: BAR }}}"); ExecutorBuilder?tester = CreateProviderTester(new BarFilterType()); // act Func <Bar, bool>?func = tester.Build <Bar>(value); // assert var a = new Bar { Foo = new Foo { BarEnum = BarEnum.BAR } }; Assert.True(func(a)); var b = new Bar { Foo = new Foo { BarEnum = BarEnum.BAZ } }; Assert.False(func(b)); }
public void Create_ObjectShortIn_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { barShort: { in: [13, 14] }}}"); ExecutorBuilder?tester = CreateProviderTester(new BarFilterInput()); // act Func <Bar, bool>?func = tester.Build <Bar>(value); // assert var a = new Bar { Foo = new Foo { BarShort = 13 } }; Assert.True(func(a)); var b = new Bar { Foo = new Foo { BarShort = 12 } }; Assert.False(func(b)); }
public void Create_ObjectStringEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { barString: { eq:\"a\" }}}"); ExecutorBuilder?tester = CreateProviderTester(new BarFilterInput()); // act Func <Bar, bool>?func = tester.Build <Bar>(value); // assert var a = new Bar { Foo = new Foo { BarString = "a" } }; Assert.True(func(a)); var b = new Bar { Foo = new Foo { BarString = "b" } }; Assert.False(func(b)); }
public void Create_NullableEnumNotIn_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ barEnum: { nin: [BAZ, QUX] }}"); ExecutorBuilder?tester = CreateProviderTester(new FooNullableFilterInput()); // act Func <FooNullable, bool>?func = tester.Build <FooNullable>(value); // assert var a = new FooNullable { BarEnum = FooEnum.BAR }; Assert.True(func(a)); var b = new FooNullable { BarEnum = FooEnum.BAZ }; Assert.False(func(b)); var c = new FooNullable { BarEnum = null }; Assert.True(func(c)); }
public void Create_ArrayNotAnyObjectStringEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ fooNested: {any: false}}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterType()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { FooNested = new[] { new FooNested { Bar = "c" }, new FooNested { Bar = "d" }, new FooNested { Bar = "a" } } }; Assert.False(func(a)); var b = new Foo { FooNested = new FooNested[] { } }; Assert.True(func(b)); var c = new Foo { FooNested = null }; Assert.False(func(c)); var d = new Foo { FooNested = new FooNested[] { null } }; Assert.False(func(d)); }
public void Create_ArraySomeObjectStringEqualWithNull_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ fooNested: {some: {bar: { eq: \"a\" }}}}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterType()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { FooNested = new[] { new FooNested { Bar = "c" }, null, new FooNested { Bar = "a" } } }; Assert.True(func(a)); var b = new Foo { FooNested = new[] { new FooNested { Bar = "c" }, null, new FooNested { Bar = "b" } } }; Assert.False(func(b)); }
public void Create_ArrayObjectNestedArraySomeStringEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ foo: { objectArray: {some: { foo: {scalarArray: {some: { eq: \"a\" }}}}}}}"); ExecutorBuilder?tester = CreateProviderTester(new BarFilterInput()); // act Func <Bar, bool>?func = tester.Build <Bar>(value); // assert var a = new Bar { Foo = new Foo { ObjectArray = new Bar[] { new Bar { Foo = new Foo { ScalarArray = new[] { "c", "d", "a" } } } } } }; Assert.True(func(a)); var b = new Bar { Foo = new Foo { ObjectArray = new Bar[] { new Bar { Foo = new Foo { ScalarArray = new[] { "c", "d", "b" } } } } } }; Assert.False(func(b)); }
public void Create_StringIn_SingleValue_Expression() { // arrange IValueNode? value = Utf8GraphQLParser.Syntax.ParseValueLiteral("{ bar: { in:[\"a\"]}}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterType()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { Bar = "a" }; Assert.True(func(a)); var b = new Foo { Bar = "b" }; Assert.False(func(b)); }
public void Create_StringNoContains_Expression() { IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: { ncontains:\"a\" }}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterType()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { Bar = "testatest" }; Assert.False(func(a)); var b = new Foo { Bar = "testbtest" }; Assert.True(func(b)); }
public void Create_ArrayAllStringEqual_Expression_Null() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: {all: { eq: null }}}"); ExecutorBuilder?tester = CreateProviderTester(new FooSimpleFilterType()); // act Func <FooSimple, bool>?func = tester.Build <FooSimple>(value); // assert var a = new FooSimple { Bar = new string[] { null, null, null } }; Assert.True(func(a)); var b = new FooSimple { Bar = new[] { "c", "d", "b" } }; Assert.False(func(b)); }
public void Create_StringNotStartsWith_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: { nstartsWith:\"a\" }}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterInput()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { Bar = "ab" }; Assert.False(func(a)); var b = new Foo { Bar = "ba" }; Assert.True(func(b)); }
public void Create_BooleanEqual_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ bar: { eq: true }}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterInput()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { Bar = true }; Assert.True(func(a)); var b = new Foo { Bar = false }; Assert.False(func(b)); }
public void Create_EnumIn_Expression() { // arrange IValueNode?value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ barEnum: { in: [BAZ, QUX] }}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterType()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { BarEnum = FooEnum.BAZ }; Assert.True(func(a)); var b = new Foo { BarEnum = FooEnum.BAR }; Assert.False(func(b)); }
public void Create_MethodComplex_Expression() { // arrange ExecutorBuilder?tester = CreateProviderTester( new FooFilterType(), new FilterConvention( x => { x.Operation(155).Name("simple"); x.Operation(156).Name("complex"); x.AddDefaults(); x.Provider( new QueryableFilterProvider( p => p.AddFieldHandler <QueryableSimpleMethodTest>() .AddFieldHandler <QueryableComplexMethodTest>() .AddDefaultFieldHandlers())); })); IValueNode?valueTrue = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ complex: {parameter:\"a\", eq:\"a\" }}"); IValueNode?valueFalse = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ complex: {parameter:\"a\", eq:\"b\" }}"); // act Func <Foo, bool>?funcTrue = tester.Build <Foo>(valueTrue); Func <Foo, bool>?funcFalse = tester.Build <Foo>(valueFalse); // assert var a = new Foo(); Assert.True(funcTrue(a)); var b = new Foo(); Assert.False(funcFalse(b)); }
public void Create_ArrayAllObjectStringEqual_Expression() { // arrange IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral( "{ fooNested: {all: { bar: {eq: \"a\" }}}}"); ExecutorBuilder?tester = CreateProviderTester(new FooFilterInput()); // act Func <Foo, bool>?func = tester.Build <Foo>(value); // assert var a = new Foo { FooNested = new[] { new FooNested { Bar = "a" }, new FooNested { Bar = "a" }, new FooNested { Bar = "a" } } }; Assert.True(func(a)); var b = new Foo { FooNested = new[] { new FooNested { Bar = "c" }, new FooNested { Bar = "a" }, new FooNested { Bar = "a" } } }; Assert.False(func(b)); var c = new Foo { FooNested = new[] { new FooNested { Bar = "a" }, new FooNested { Bar = "d" }, new FooNested { Bar = "b" } } }; Assert.False(func(c)); var d = new Foo { FooNested = new[] { new FooNested { Bar = "c" }, new FooNested { Bar = "d" }, new FooNested { Bar = "b" } } }; Assert.False(func(d)); var e = new Foo { FooNested = new[] { null, new FooNested { Bar = null }, new FooNested { Bar = "d" }, new FooNested { Bar = "b" } } }; Assert.False(func(e)); }