コード例 #1
0
        public void InferTypeFromProperty()
        {
            // act
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // assert
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.Equal(typeof(FieldCollection <InputField>),
                         description.TypeReference.ClrType);
            Assert.Equal("arguments", description.Name);
        }
コード例 #2
0
        public void OverwriteName()
        {
            // arrange
            var descriptor = new InputFieldDescriptor("1234");

            // act
            ((IInputFieldDescriptor)descriptor)
            .Name("args");

            // assert
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.Equal("args", description.Name);
        }
コード例 #3
0
        public void OverwriteName2()
        {
            // arrange
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .Name("args");

            // assert
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.Equal("args", description.Name);
        }
コード例 #4
0
        public void SetDefaultValueAndInferType()
        {
            // arrange
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .DefaultValue("string");

            // assert
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.Equal(typeof(string), description.TypeReference.ClrType);
            Assert.Equal("string", description.NativeDefaultValue);
        }
コード例 #5
0
        public void SetDescription()
        {
            // arrange
            string expectedDescription = Guid.NewGuid().ToString();
            var    descriptor          = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .Description(expectedDescription);

            // assert
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.Equal(expectedDescription, description.Description);
        }
コード例 #6
0
        public void SetSchemaType()
        {
            // arrange
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .Type(new StringType());

            // assert
            InputFieldDescription description = descriptor.CreateDescription();
            TypeReference         typeRef     = description.TypeReference;

            Assert.IsType <StringType>(typeRef.SchemaType);
        }
コード例 #7
0
        public void SchemaTypesOverwriteDotNetTypes()
        {
            // arrange
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .Type <NativeType <IReadOnlyDictionary <string, string> > >()
            .Type <ListType <StringType> >();

            // assert
            InputFieldDescription description = descriptor.CreateDescription();
            TypeReference         typeRef     = description.TypeReference;

            Assert.Equal(typeof(ListType <StringType>), typeRef.ClrType);
        }
コード例 #8
0
        public void OverwriteDefaultValueLiteralWithNativeDefaultValue()
        {
            // arrange
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .DefaultValue(new StringValueNode("123"))
            .DefaultValue("string");

            // asser
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.Null(description.DefaultValue);
            Assert.Equal("string", description.NativeDefaultValue);
        }
コード例 #9
0
        public void SettingTheNativeDefaultValueToNullCreatesNullLiteral()
        {
            // arrange
            var descriptor = new InputFieldDescriptor(
                typeof(ObjectField).GetProperty("Arguments"));

            // act
            ((IInputFieldDescriptor)descriptor)
            .DefaultValue(new StringValueNode("123"))
            .DefaultValue("string")
            .DefaultValue(null);

            // assert
            InputFieldDescription description = descriptor.CreateDescription();

            Assert.IsType <NullValueNode>(description.DefaultValue);
            Assert.Null(description.NativeDefaultValue);
        }