Skip to content

Commit

Permalink
Update enum unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tlil committed Mar 27, 2017
1 parent 64d2604 commit c9c078f
Showing 1 changed file with 29 additions and 6 deletions.
35 changes: 29 additions & 6 deletions test/Tests/Adapters/Engine/GraphQLEngineTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using GraphQL.Conventions.Tests.Adapters.Engine.Types;
using GraphQL.Conventions.Tests.Templates;
using GraphQL.Conventions.Tests.Templates.Extensions;
Expand Down Expand Up @@ -99,14 +100,15 @@ enum Enum1 {
input InputObject {
anotherField: RenamedEnum
someField: RenamedEnum = SOME_VALUE1
yetAnotherDummyField: RenamedEnum! = SOME_VALUE2
yetAnotherDummyField: RenamedEnum = SOME_VALUE2
yetAnotherField: RenamedEnum!
}
type QueryWithEnums {
field1: Enum1!
field2: RenamedEnum
field3(arg1: RenamedEnum, arg2: Enum1!, arg3: RenamedEnum! = SOME_VALUE2, arg4: Enum1 = OPTION3): RenamedEnum!
field3(arg1: RenamedEnum, arg2: Enum1!, arg3: RenamedEnum = SOME_VALUE2, arg4: Enum1 = OPTION3): RenamedEnum!
field4(input: InputObject): RenamedEnum
field5(arg: Enum1): Enum1
}
enum RenamedEnum {
SOME_VALUE1
Expand All @@ -115,6 +117,26 @@ enum RenamedEnum {
");
}

[Test]
public async Task Can_Evaluate_Enums_Arguments_With_Default_Values()
{
var executor = GraphQLEngine
.New<QueryWithEnums>()
.NewExecutor();
var result = await executor
.WithQueryString(@"
{
field3(arg2: OPTION3)
field4(input: { yetAnotherField: SOME_VALUE1 })
field5
}")
.Execute();

result.Data.ShouldHaveFieldWithValue("field3", "SOME_VALUE2");
result.Data.ShouldHaveFieldWithValue("field4", "SOME_VALUE2");
result.Data.ShouldHaveFieldWithValue("field5", null);
}

[Test]
public void Can_Construct_And_Describe_Schema_With_Interfaces()
{
Expand Down Expand Up @@ -288,10 +310,11 @@ class QueryWithEnums

public Enum2? Field2 => Enum2.SomeValue1;

public Enum2 Field3(Enum2? arg1, Enum1 arg2, Enum2 arg3 = Enum2.SomeValue2, Enum1? arg4 = Enum1.Option3) => arg3;
public Enum2 Field3(Enum2? arg1, Enum1 arg2, Enum2? arg3 = Enum2.SomeValue2, Enum1? arg4 = Enum1.Option3) => arg3 ?? Enum2.SomeValue1;

public Enum2? Field4(InputObject input) => input.YetAnotherDummyField;

[DefaultValue(Enum2.SomeValue1)]
public Enum2? Field4(InputObject input) => Enum2.SomeValue1;
public Enum1? Field5(Enum1? arg = null) => arg;
}

enum Enum1
Expand Down Expand Up @@ -319,7 +342,7 @@ class InputObject
public Enum2 YetAnotherField { get; set; }

[DefaultValue(Enum2.SomeValue2)]
public Enum2 YetAnotherDummyField { get; set; }
public Enum2? YetAnotherDummyField { get; set; }
}

class QueryWithInterfaces
Expand Down

0 comments on commit c9c078f

Please sign in to comment.