예제 #1
0
        public void Sort_NullableStringDescWithNull(params string[] data)
        {
            IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral(
                "{ bar: { baz: DESC}}");
            ExecutorBuilder tester = CreateProviderTester(new FooNullableSortType <string>());

            string?[] expected = data.OrderByDescending(x => x).Append(null).ToArray();

            // act
            Func <FooNullable <string>[], FooNullable <string>[]> func =
                tester.Build <FooNullable <string> >(value);

            // assert
            FooNullable <string>[] inputs =
                data.Select(x => new FooNullable <string> {
                Bar = new BarNullable <string> {
                    Baz = x
                }
            })
                .Append(new FooNullable <string> {
                Bar = null
            })
                .ToArray();
            FooNullable <string>[] sorted = func(inputs);

            for (var i = 0; i < expected.Length; i++)
            {
                Assert.Equal(expected[i], sorted[i].Bar?.Baz);
            }
        }
예제 #2
0
        protected void Test_Desc <T>(params T[] data)
        {
            // arrange
            IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral(
                "{ bar: { baz: DESC}}");
            ExecutorBuilder tester = CreateProviderTester(new FooSortType <T>());

            T[] expected = data.OrderByDescending(x => x).ToArray();

            // act
            Func <Foo <T>[], Foo <T>[]> func = tester.Build <Foo <T> >(value);

            // assert
            Foo <T>[] inputs = data.Select(x => new Foo <T> {
                Bar = new Bar <T> {
                    Baz = x
                }
            }).ToArray();
            Foo <T>[] sorted = func(inputs);

            for (var i = 0; i < expected.Length; i++)
            {
                Assert.Equal(expected[i], sorted[i].Bar.Baz);
            }
        }
        public void Sort_Interface_BooleanAsc(params bool[] dataObject)
        {
            IValueNode value = Utf8GraphQLParser.Syntax.ParseValueLiteral(
                "{ test: { prop: ASC}}");
            ExecutorBuilder tester = CreateProviderTester(new SortInputType <BarInterface>());

            bool[] expected = dataObject.OrderBy(x => x).ToArray();

            // act
            Func <BarInterface[], BarInterface[]> func = tester.Build <BarInterface>(value);

            // assert
            BarInterface[] inputs = dataObject
                                    .Select(x => new BarInterface {
                Test = new InterfaceImpl1 {
                    Prop = x
                }
            })
                                    .ToArray();
            BarInterface[] sorted = func(inputs);

            for (var i = 0; i < expected.Length; i++)
            {
                Assert.Equal(expected[i], sorted[i].Test.Prop);
            }
        }