コード例 #1
0
        public void Convert_InputObjectWithNullField_Dictionary()
        {
            // arrange
            ISchema schema = Schema.Create(
                c => c.RegisterType <InputObjectType <Foo> >());

            var type = schema.GetType <InputObjectType>("FooInput");

            var bar2 = new Bar {
                Number = 2, Baz = Baz.Bar
            };
            var bar3 = new Bar {
                Number = 3, Baz = Baz.Foo
            };
            var foo = new Foo
            {
                Bar  = null,
                Bars = new List <Bar> {
                    bar2, bar3
                }
            };

            // act
            var converter = new InputObjectToDictionaryConverter(
                TypeConversion.Default);
            Dictionary <string, object> dict = converter.Convert(type, foo);

            // assert
            dict.Snapshot();
        }
コード例 #2
0
        public void Convert_InputObjectWithNullElement_Dictionary()
        {
            // arrange
            ISchema schema = Schema.Create(
                c =>
            {
                c.RegisterQueryType <DummyQuery>();
                c.RegisterType <InputObjectType <Foo> >();
            });

            InputObjectType type = schema.GetType <InputObjectType>("FooInput");

            var bar1 = new Bar {
                Number = 1, Baz = Baz.Bar
            };
            var bar2 = new Bar {
                Number = 2, Baz = Baz.Bar
            };
            var foo = new Foo
            {
                Bar  = bar1,
                Bars = new List <Bar> {
                    bar2, null
                }
            };

            // act
            var converter = new InputObjectToDictionaryConverter(
                TypeConversion.Default);
            Dictionary <string, object> dict = converter.Convert(type, foo);

            // assert
            dict.MatchSnapshot();
        }
コード例 #3
0
        public void Convert_InputObjectWithNullField_Dictionary()
        {
            // arrange
            ISchema schema = SchemaBuilder.New()
                             .AddQueryType <DummyQuery>()
                             .AddType <InputObjectType <Foo> >()
                             .Create();

            InputObjectType type = schema.GetType <InputObjectType>("FooInput");

            var bar2 = new Bar {
                Number = 2, Baz = Baz.Bar
            };
            var bar3 = new Bar {
                Number = 3, Baz = Baz.Foo
            };
            var foo = new Foo
            {
                Bar  = null,
                Bars = new List <Bar> {
                    bar2, bar3
                }
            };

            // act
            var converter = new InputObjectToDictionaryConverter(
                DefaultTypeConverter.Default);
            Dictionary <string, object> dict = converter.Convert(type, foo);

            // assert
            dict.MatchSnapshot();
        }