forked from ChilliCream/graphql-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved GraphQLClientException message when there is only one GraphQ…
…L error. (ChilliCream#4528)
- Loading branch information
Showing
2 changed files
with
74 additions
and
6 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
55 changes: 55 additions & 0 deletions
55
src/StrawberryShake/Client/test/Core.Tests/GraphQLClientExceptionTests.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,55 @@ | ||
using Xunit; | ||
|
||
namespace StrawberryShake | ||
{ | ||
public class GraphQLClientExceptionTests | ||
{ | ||
[Fact] | ||
public void Constructor_ZeroErrors() | ||
{ | ||
//arrange | ||
var errors = new IClientError[0]; | ||
|
||
//act | ||
var exception = new GraphQLClientException(errors); | ||
|
||
//assert | ||
Assert.Equal("Unknown error occurred", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_OneError() | ||
{ | ||
//arrange | ||
var errors = new IClientError[] | ||
{ | ||
new ClientError("some message"), | ||
}; | ||
|
||
//act | ||
var exception = new GraphQLClientException(errors); | ||
|
||
//assert | ||
Assert.Equal("some message", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_TwoErrors() | ||
{ | ||
//arrange | ||
var errors = new IClientError[] | ||
{ | ||
new ClientError("first message"), | ||
new ClientError("second message"), | ||
}; | ||
|
||
//act | ||
var exception = new GraphQLClientException(errors); | ||
|
||
//assert | ||
Assert.Equal(@"Multiple errors occurred: | ||
- first message | ||
- second message", exception.Message.Replace("\r", "")); | ||
} | ||
} | ||
} |