public void Empty() { var typeConstructor = new TypeConstructor(); var type = (ObjectGraphType)typeConstructor.Derive(Entity.New(typeof(Data.Empty))); type.ShouldBeType <ObjectType <Data.Empty> >(); type.Name.ShouldEqual(nameof(Data.Empty)); type.Description.ShouldEqual(null); type.Interfaces.ShouldBeEmpty(); type.Fields.ShouldBeEmpty(); }
public void OverriddenNameAndDescription() { var typeConstructor = new TypeConstructor(); var type = (ObjectGraphType)typeConstructor.Derive(Entity.New(typeof(Data.OverriddenNameAndDescription))); type.ShouldBeType <ObjectType <Data.OverriddenNameAndDescription> >(); type.Name.ShouldEqual("EmptyOverride"); type.Description.ShouldEqual("Lorem ipsum"); type.Interfaces.ShouldBeEmpty(); type.Fields.ShouldBeEmpty(); }
public void FieldTypes() { var typeConstructor = new TypeConstructor(); var type = (ObjectGraphType)typeConstructor.Derive(Entity.New(typeof(Data.Foo))); type.ShouldBeType <ObjectType <Data.Foo> >(); type.Interfaces.ShouldBeEmpty(); type.Fields.Count().ShouldEqual(3); var field = type.ShouldHaveField("field"); field.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Foo.Field))); field.Description.ShouldEqual("Hello"); field.DeprecationReason.ShouldEqual("World"); field.Arguments.ShouldBeEmpty(); field.DefaultValue.ShouldBeNull(); field.Type.ShouldEqual(typeof(StringGraphType)); var property = type.ShouldHaveField("property"); property.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Foo.Property))); property.Description.ShouldEqual(null); property.DeprecationReason.ShouldEqual(null); property.Arguments.ShouldBeEmpty(); property.DefaultValue.ShouldBeNull(); property.Type.ShouldEqual(typeof(NonNullGraphType <IntGraphType>)); var method = type.ShouldHaveField("method"); method.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Foo.Method))); method.Description.ShouldEqual(null); method.DeprecationReason.ShouldEqual(null); method.Arguments.Count.ShouldEqual(2); method.DefaultValue.ShouldBeNull(); method.Type.ShouldEqual(typeof(BooleanGraphType)); var arg1 = method.Arguments[0]; arg1.Name.ShouldEqual("a"); arg1.Description.ShouldEqual("abc"); arg1.Type.ShouldEqual(typeof(IntGraphType)); arg1.DefaultValue.ShouldBeNull(); var arg2 = method.Arguments[1]; arg2.Name.ShouldEqual("b"); arg2.Description.ShouldEqual(null); arg2.Type.ShouldEqual(typeof(NonNullGraphType <FloatGraphType>)); arg1.DefaultValue.ShouldEqual(1.0f); }
public void Tasks() { var typeConstructor = new TypeConstructor(); var type = (ObjectGraphType)typeConstructor.Derive(Entity.New(typeof(Data.Baz))); type.ShouldBeType <ObjectType <Data.Baz> >(); type.Interfaces.ShouldBeEmpty(); type.Fields.Count().ShouldEqual(1); var field = type.ShouldHaveField("findInt"); field.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Baz.FindInt))); field.Type.ShouldEqual(typeof(NonNullGraphType <IntGraphType>)); field.Arguments.Count.ShouldEqual(1); var arg = field.Arguments[0]; arg.Name.ShouldEqual("input"); arg.Type.ShouldEqual(typeof(IntGraphType)); arg.DefaultValue.ShouldBeNull(); }
public void FieldTypes() { var typeConstructor = new TypeConstructor(); var entity = Entity.New(typeof(Data.Foo)); var type = (ObjectGraphType)typeConstructor.Derive(entity); type.ShouldBeType <ObjectType <Data.Foo> >(); type.Interfaces.ShouldBeEmpty(); type.Fields.Count().ShouldEqual(3); var field = type.ShouldHaveField("field"); field.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Foo.Field))); field.Description.ShouldEqual("Hello"); field.DeprecationReason.ShouldEqual("World"); field.Arguments.ShouldBeEmpty(); field.DefaultValue.ShouldBeNull(); field.Type.ShouldEqual(typeof(StringGraphType)); var property = type.ShouldHaveField("property"); property.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Foo.Property))); property.Description.ShouldEqual(null); property.DeprecationReason.ShouldEqual(null); property.Arguments.ShouldBeEmpty(); property.DefaultValue.ShouldBeNull(); property.Type.ShouldEqual(typeof(NonNullGraphType <IntGraphType>)); var method = type.ShouldHaveField("method"); method.Name.ShouldEqual(NameAttribute.AsFieldName(nameof(Data.Foo.Method))); method.Description.ShouldEqual(null); method.DeprecationReason.ShouldEqual(null); method.Arguments.Count.ShouldEqual(2); method.DefaultValue.ShouldBeNull(); method.Type.ShouldEqual(typeof(NonNullGraphType <EnumType <Data.Baz> >)); var arg1 = method.Arguments[0]; arg1.Name.ShouldEqual("foo"); arg1.Description.ShouldEqual(null); arg1.Type.ShouldEqual(typeof(InputObjectType <Data.Foo>)); arg1.DefaultValue.ShouldBeNull(); var arg2 = method.Arguments[1]; arg2.Name.ShouldEqual("baz"); arg2.Description.ShouldEqual(null); arg2.Type.ShouldEqual(typeof(EnumType <Data.Baz>)); arg2.DefaultValue.ShouldBeNull(); var entityField = entity.Fields.First(f => f.Name == "method"); var entityArg1 = entityField.Arguments[0]; entityArg1.WrappedType.Entity.IsInput.ShouldBeTrue(); var entityArg2 = entityField.Arguments[1]; entityArg2.WrappedType.Entity.IsInput.ShouldBeTrue(); }