public void CreateInterfaceType() { // arrange InterfaceTypeDefinitionNode typeDefinition = CreateTypeDefinition <InterfaceTypeDefinitionNode>( "interface Simple { a: String b: [String] }"); // act var factory = new InterfaceTypeFactory(); InterfaceType type = factory.Create(typeDefinition); CompleteType(type); // assert Assert.Equal("Simple", type.Name); Assert.Equal(2, type.Fields.Count); Assert.True(type.Fields.ContainsField("a")); Assert.False(type.Fields["a"].Type.IsNonNullType()); Assert.False(type.Fields["a"].Type.IsListType()); Assert.True(type.Fields["a"].Type.IsScalarType()); Assert.Equal("String", type.Fields["a"].Type.TypeName()); Assert.True(type.Fields.ContainsField("b")); Assert.False(type.Fields["b"].Type.IsNonNullType()); Assert.True(type.Fields["b"].Type.IsListType()); Assert.False(type.Fields["b"].Type.IsScalarType()); Assert.Equal("String", type.Fields["b"].Type.TypeName()); }
public static void Main() { IInterfaceType t1 = InterfaceTypeFactory.NewObjectByClassName("ClassA"); IInterfaceType t2 = InterfaceTypeFactory.NewObjectByClassName("ClassB"); IInterfaceType t3 = InterfaceTypeFactory.NewObjectByClassName("ClassC"); Console.WriteLine(t1.Message); Console.WriteLine(t2.Message); Console.WriteLine(t3.Message); }
public void InterfaceFieldDeprecationReason() { // arrange InterfaceTypeDefinitionNode typeDefinition = CreateTypeDefinition <InterfaceTypeDefinitionNode>(@" interface Simple { a: String @deprecated(reason: ""reason123"") }"); // act var factory = new InterfaceTypeFactory(); InterfaceType type = factory.Create(typeDefinition); CompleteType(type); // assert Assert.True(type.Fields["a"].IsDeprecated); Assert.Equal("reason123", type.Fields["a"].DeprecationReason); }