private void CompleteFields() { var fields = new Dictionary <string, InputFieldDescription>(); var handledProperties = new HashSet <PropertyInfo>(); foreach (InputFieldDescriptor fieldDescriptor in Fields) { InputFieldDescription fieldDescription = fieldDescriptor .CreateDescription(); if (!fieldDescription.Ignored) { fields[fieldDescription.Name] = fieldDescription; } if (fieldDescription.Property != null) { handledProperties.Add(fieldDescription.Property); } } OnCompleteFields(fields, handledProperties); ObjectDescription.Fields.AddRange(fields.Values); }
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); }
public void OverwriteName() { // arrange var descriptor = new InputFieldDescriptor("1234"); // act ((IInputFieldDescriptor)descriptor) .Name("args"); // assert InputFieldDescription description = descriptor.CreateDescription(); Assert.Equal("args", description.Name); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
internal InputField(InputFieldDescription inputFieldDescription) : this(inputFieldDescription, DirectiveLocation.InputFieldDefinition) { Property = inputFieldDescription.Property; }
internal InputField(InputFieldDescription inputFieldDescription) : this((ArgumentDescription)inputFieldDescription) { Property = inputFieldDescription.Property; }