public void InferTypeFromProperty() { // act var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.Equal(typeof(List <Argument>), Assert.IsType <ClrTypeReference>(description.Type).Type); Assert.Equal("arguments", description.Name); }
public void OverwriteName2() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor.Name("args"); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.Equal("args", description.Name); }
public void OverwriteName() { // arrange var descriptor = InputFieldDescriptor.New( Context, "field1234"); // act descriptor.Name("args"); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.Equal("args", description.Name); }
public void SetDescription() { // arrange string expectedDescription = Guid.NewGuid().ToString(); var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor.Description(expectedDescription); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.Equal(expectedDescription, description.Description); }
public void SetSchemaType() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor.Type(new StringType()); // assert InputFieldDefinition description = descriptor.CreateDefinition(); ITypeReference typeRef = description.Type; Assert.IsType <StringType>( Assert.IsType <SchemaTypeReference>(typeRef).Type); }
public void SetDefaultValueAndInferType() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor.DefaultValue("string"); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.Equal(typeof(string), Assert.IsType <ClrTypeReference>(description.Type).Type); Assert.Equal("string", description.NativeDefaultValue); }
public void SetNonGenericType() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor.Type(typeof(StringType)); // assert InputFieldDefinition description = descriptor.CreateDefinition(); ITypeReference typeRef = description.Type; Assert.Equal( typeof(StringType), Assert.IsType <ClrTypeReference>(typeRef).Type); }
public void OverwriteDefaultValueLiteralWithNativeDefaultValue() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor .DefaultValue(new StringValueNode("123")) .DefaultValue("string"); // asser InputFieldDefinition description = descriptor.CreateDefinition(); Assert.Null(description.DefaultValue); Assert.Equal("string", description.NativeDefaultValue); }
public void SchemaTypesOverwriteDotNetTypes() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act descriptor .Type <NativeType <IReadOnlyDictionary <string, string> > >() .Type <ListType <StringType> >(); // assert InputFieldDefinition description = descriptor.CreateDefinition(); ITypeReference typeRef = description.Type; Assert.Equal(typeof(ListType <StringType>), Assert.IsType <ClrTypeReference>(typeRef).Type); }
public void SettingTheNativeDefaultValueToNullCreatesNullLiteral() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act ((IInputFieldDescriptor)descriptor) .DefaultValue(new StringValueNode("123")) .DefaultValue("string") .DefaultValue(null); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.IsType <NullValueNode>(description.DefaultValue); Assert.Null(description.NativeDefaultValue); }
public void OverwriteNativeDefaultValueWithDefaultValueLiteral() { // arrange var descriptor = InputFieldDescriptor.New( Context, typeof(ObjectField).GetProperty("Arguments")); // act ((IInputFieldDescriptor)descriptor) .DefaultValue("string") .DefaultValue(new StringValueNode("123")); // assert InputFieldDefinition description = descriptor.CreateDefinition(); Assert.IsType <StringValueNode>(description.DefaultValue); Assert.Equal("123", ((StringValueNode)description.DefaultValue).Value); Assert.Null(description.NativeDefaultValue); }
public void Type_Syntax_Type_Null() { void Error() => InputFieldDescriptor.New(Context, "foo").Type((string)null); Assert.Throws <ArgumentNullException>(Error); }