Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
Shane32 committed Nov 17, 2021
commit 96c9127f5bfca88447b107043ff689dfa16bd014
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 MySchemaTypes() : base(new Schema(), Mock.Of<IServiceProvider>(), true, t
}

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; }
}
}
}