-
-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stitching Introspection Fixes (#671)
- Loading branch information
1 parent
dff5c2b
commit 71ec0ab
Showing
27 changed files
with
2,020 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
using System; | ||
using Xunit; | ||
|
||
namespace HotChocolate.Language | ||
{ | ||
public class ValueParserTests | ||
{ | ||
[InlineData("true", true, typeof(BooleanValueNode))] | ||
[InlineData("false", false, typeof(BooleanValueNode))] | ||
[InlineData("0", "0", typeof(IntValueNode))] | ||
[InlineData("123", "123", typeof(IntValueNode))] | ||
[InlineData("-123", "-123", typeof(IntValueNode))] | ||
[InlineData("2.3e-5", "2.3e-5", typeof(FloatValueNode))] | ||
[InlineData("2.3e+5", "2.3e+5", typeof(FloatValueNode))] | ||
[InlineData("123.456", "123.456", typeof(FloatValueNode))] | ||
[InlineData("\"123\"", "123", typeof(StringValueNode))] | ||
[InlineData("\"\"\"123\n456\"\"\"", "123\n456", | ||
typeof(StringValueNode))] | ||
[InlineData("\"\\u0031\"", "1", typeof(StringValueNode))] | ||
[InlineData("\"\\u004E\"", "N", typeof(StringValueNode))] | ||
[InlineData("\"\\u0061\"", "a", typeof(StringValueNode))] | ||
[InlineData("\"\\u003A\"", ":", typeof(StringValueNode))] | ||
[InlineData("FOO", "FOO", typeof(EnumValueNode))] | ||
[Theory] | ||
public void ParseSimpleValue( | ||
string value, | ||
object expectedValue, | ||
Type expectedNodeType) | ||
{ | ||
// arrange | ||
// act | ||
IValueNode valueNode = ParseValue(value); | ||
|
||
// assert | ||
Assert.Equal(expectedNodeType, valueNode.GetType()); | ||
Assert.Equal(expectedValue, valueNode.Value); | ||
} | ||
|
||
[Fact] | ||
public void ZeroZeroIsNotAllowed() | ||
{ | ||
// arrange | ||
// act | ||
Action action = () => ParseValue("00"); | ||
|
||
// assert | ||
Assert.Throws<SyntaxException>(action); | ||
} | ||
|
||
private static IValueNode ParseValue(string value) | ||
{ | ||
SyntaxToken start = Lexer.Default.Read( | ||
new Source(value)); | ||
|
||
var context = new ParserContext( | ||
new Source(value), | ||
start, | ||
ParserOptions.Default, | ||
Parser.ParseName); | ||
context.MoveNext(); | ||
|
||
return Parser.ParseValueLiteral(context, true); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
src/Stitching/Stitching.Tests/Introspection/IntrospectionClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
using HotChocolate.Language; | ||
using Snapshooter.Xunit; | ||
using Xunit; | ||
|
||
namespace HotChocolate.Stitching.Introspection | ||
{ | ||
public class IntrospectionClientTests | ||
{ | ||
[Fact] | ||
public void IntrospectionWithSubscription() | ||
{ | ||
// arrange | ||
var features = new SchemaFeatures | ||
{ | ||
HasSubscriptionSupport = true | ||
}; | ||
|
||
// act | ||
DocumentNode document = | ||
IntrospectionClient.CreateIntrospectionQuery(features); | ||
|
||
// assert | ||
QuerySyntaxSerializer.Serialize(document).MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public void IntrospectionWithoutSubscription() | ||
{ | ||
// arrange | ||
var features = new SchemaFeatures | ||
{ | ||
HasSubscriptionSupport = false | ||
}; | ||
|
||
// act | ||
DocumentNode document = | ||
IntrospectionClient.CreateIntrospectionQuery(features); | ||
|
||
// assert | ||
QuerySyntaxSerializer.Serialize(document).MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public void IntrospectionWithDirectiveLocationField() | ||
{ | ||
// arrange | ||
var features = new SchemaFeatures | ||
{ | ||
HasDirectiveLocations = true | ||
}; | ||
|
||
// act | ||
DocumentNode document = | ||
IntrospectionClient.CreateIntrospectionQuery(features); | ||
|
||
// assert | ||
QuerySyntaxSerializer.Serialize(document).MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public void IntrospectionWithoutDirectiveLocationField() | ||
{ | ||
// arrange | ||
var features = new SchemaFeatures | ||
{ | ||
HasDirectiveLocations = false | ||
}; | ||
|
||
// act | ||
DocumentNode document = | ||
IntrospectionClient.CreateIntrospectionQuery(features); | ||
|
||
// assert | ||
QuerySyntaxSerializer.Serialize(document).MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public void IntrospectionWithDirectiveIsRepeatableField() | ||
{ | ||
// arrange | ||
var features = new SchemaFeatures | ||
{ | ||
HasRepeatableDirectives = true | ||
}; | ||
|
||
// act | ||
DocumentNode document = | ||
IntrospectionClient.CreateIntrospectionQuery(features); | ||
|
||
// assert | ||
QuerySyntaxSerializer.Serialize(document).MatchSnapshot(); | ||
} | ||
|
||
[Fact] | ||
public void IntrospectionWithoutDirectiveIsRepeatableField() | ||
{ | ||
// arrange | ||
var features = new SchemaFeatures | ||
{ | ||
HasRepeatableDirectives = false | ||
}; | ||
|
||
// act | ||
DocumentNode document = | ||
IntrospectionClient.CreateIntrospectionQuery(features); | ||
|
||
// assert | ||
QuerySyntaxSerializer.Serialize(document).MatchSnapshot(); | ||
} | ||
} | ||
} |
Oops, something went wrong.