Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79e2d5e
commit cbe8298
Showing
7 changed files
with
111 additions
and
12 deletions.
There are no files selected for viewing
4 changes: 0 additions & 4 deletions
4
...hemaBuilderExtensions.Bindings.Tests.1.cs → ...SchemaBuilderExtensions.Bindings.Tests.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
74 changes: 74 additions & 0 deletions
74
src/Core/Types.Tests/Extensions/SchemaBuilderExtensions.Document.Tests.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,74 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using Xunit; | ||
using Snapshooter.Xunit; | ||
using HotChocolate.Types; | ||
using IOPath = System.IO.Path; | ||
|
||
namespace HotChocolate | ||
{ | ||
public class SchemaBuilderExtensionsDocumentTests | ||
{ | ||
[Fact] | ||
public void AddDocumentFromFile_Builder_Is_Null() | ||
{ | ||
// arrange | ||
// act | ||
Action action = () => | ||
SchemaBuilderExtensions.AddDocumentFromFile(null, "abc"); | ||
|
||
// assert | ||
Assert.Throws<ArgumentNullException>(action); | ||
} | ||
|
||
[Fact] | ||
public void AddDocumentFromFile_File_Is_Null() | ||
{ | ||
// arrange | ||
var builder = SchemaBuilder.New(); | ||
|
||
// act | ||
Action action = () => | ||
SchemaBuilderExtensions.AddDocumentFromFile(builder, null); | ||
|
||
// assert | ||
Assert.Throws<ArgumentException>(action); | ||
} | ||
|
||
[Fact] | ||
public void AddDocumentFromFile_File_Is_Empty() | ||
{ | ||
// arrange | ||
var builder = SchemaBuilder.New(); | ||
|
||
// act | ||
Action action = () => | ||
SchemaBuilderExtensions.AddDocumentFromFile( | ||
builder, string.Empty); | ||
|
||
// assert | ||
Assert.Throws<ArgumentException>(action); | ||
} | ||
|
||
[Fact] | ||
public async Task AddDocumentFromFile() | ||
{ | ||
// arrange | ||
var builder = SchemaBuilder.New(); | ||
string file = IOPath.GetTempFileName(); | ||
await File.WriteAllTextAsync(file, "type Query { a: String }"); | ||
|
||
// act | ||
SchemaBuilderExtensions.AddDocumentFromFile(builder, file); | ||
|
||
// assert | ||
ISchema schema = builder | ||
.Use(next => context => next.Invoke(context)) | ||
.Create(); | ||
|
||
schema.ToString().MatchSnapshot(); | ||
} | ||
} | ||
} | ||
|
6 changes: 3 additions & 3 deletions
6
src/Core/Types.Tests/Extensions/SchemaBuilderExtensions.Resolvers.Tests.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
2 changes: 1 addition & 1 deletion
2
src/Core/Types.Tests/Extensions/SchemaBuilderExtensions.Types.Tests.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
10 changes: 10 additions & 0 deletions
10
...ts/Extensions/__snapshots__/SchemaBuilderExtensionsDocumentTests.AddDocumentFromFile.snap
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,10 @@ | ||
schema { | ||
query: Query | ||
} | ||
|
||
type Query { | ||
a: String | ||
} | ||
|
||
"The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text." | ||
scalar String |
2 changes: 0 additions & 2 deletions
2
src/Core/Types/Extensions/SchemaBuilderExtensions.Bindings.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
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