Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shane32 committed Nov 17, 2021
1 parent 7f7f955 commit 96c9127
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
38 changes: 0 additions & 38 deletions src/Tests/DISchemaTypesTests.cs

This file was deleted.

30 changes: 29 additions & 1 deletion src/Tests/Execution/DISchemaTypes.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using GraphQL;
using GraphQL.DI;
using GraphQL.Types;
using Moq;
Expand All @@ -13,7 +14,7 @@ public class DISchemaTypesTests
[Theory]
[InlineData(typeof(int), false, typeof(IntGraphType))]
[InlineData(typeof(int), true, typeof(IntGraphType))]
[InlineData(typeof(Class1), false, null)]
[InlineData(typeof(Class1), false, typeof(AutoObjectGraphType<Class1>))]
[InlineData(typeof(Class1), true, typeof(AutoInputObjectGraphType<Class1>))]
public void GetGraphTypeFromClrType(Type clrType, bool isInputType, Type graphType)
{
Expand All @@ -31,5 +32,32 @@ public new Type GetGraphTypeFromClrType(Type clrType, bool isInputType, List<(Ty
}

private class Class1 { }

[Fact]
public void InputOutputTypesWork()
{
var schema = new Schema();
schema.Query = new ObjectGraphType();
var newField = new FieldType { Name = "Test", Type = typeof(GraphQLClrOutputTypeReference<Class1Model>) };
newField.Arguments = new QueryArguments(new QueryArgument<GraphQLClrInputTypeReference<Class2InputModel>> { Name = "arg" });
schema.Query.AddField(newField);
var schemaTypes = new DISchemaTypes(schema, new DefaultServiceProvider());
var class1Type = schemaTypes["Class1"].ShouldBeAssignableTo<IObjectGraphType>();
class1Type.Fields.Count.ShouldBe(1);
class1Type.Fields.Find("value").ShouldNotBeNull();
var class2Type = schemaTypes["Class2Input"].ShouldBeAssignableTo<IInputObjectGraphType>();
class2Type.Fields.Count.ShouldBe(1);
class2Type.Fields.Find("value").ShouldNotBeNull();
}

private class Class1Model
{
public int Value { get; set; }
}

private class Class2InputModel
{
public int Value { get; set; }
}
}
}

0 comments on commit 96c9127

Please sign in to comment.