Files
speckle-sharp-sdk/tests/Speckle.Core.Tests.Integration/GraphQLCLient.cs
T
Adam Hathcock 200b84f49a Main to dev (#18)
* Add Instances base (#6)

* Use Uri for checks in GetAccounts function (#8)

* Add integration and perf tests to sln (#9)

* Remove perf tests (#10)

* remove perf tests

* do all unit tests

* Code coverage (#11)

* code coverage

* enable codecov for GA

* Update README.md

* Update coverage and dependencies (#12)

* Update coverage and dependencies

* fmt

* add codecov config

* merge DUI3/Alpha into sdk (#13)

* merge DUI3/Alpha into sdk

* formatting

* Merge Objects dui3/alpha -> dev (#14)

* merge DUI3/Alpha into sdk

* formatting

* Objects changes

* Objects tests

* Unit test project

* update codecov to be less intrusive (#15)

* update codecov to be less intrusive

* fix codecov yaml

* add coverage exclusion

* Merge sharp `dui3/alpha` -> sdk `main` (#16)

* Merge

* csharpier format

* Fixed polysharp issues

* Integration Tests

* Fixes

* Some nullability fixes (#17)

* add coverage exclusion

* fix some tests and fix nullability errors

---------

Co-authored-by: Oğuzhan Koral <45078678+oguzhankoral@users.noreply.github.com>
Co-authored-by: Jedd Morgan <45512892+JR-Morgan@users.noreply.github.com>
2024-07-09 13:56:03 +01:00

65 lines
1.3 KiB
C#

using GraphQL;
using Speckle.Core.Api;
using Speckle.Core.Credentials;
namespace Speckle.Core.Tests.Integration;
public class GraphQLClientTests : IDisposable
{
private Account _account;
private Client _client;
[OneTimeSetUp]
public async Task Setup()
{
_account = await Fixtures.SeedUser();
_client = new Client(_account);
}
[Test]
public void ThrowsForbiddenException()
{
Assert.ThrowsAsync<SpeckleGraphQLForbiddenException>(
async () =>
await _client.ExecuteGraphQLRequest<Dictionary<string, object>>(
new GraphQLRequest
{
Query =
@"query {
adminStreams{
totalCount
}
}"
}
)
);
}
[Test]
public void Cancellation()
{
using CancellationTokenSource tokenSource = new();
tokenSource.Cancel();
Assert.CatchAsync<OperationCanceledException>(
async () =>
await _client.ExecuteGraphQLRequest<Dictionary<string, object>>(
new GraphQLRequest
{
Query =
@"query {
adminStreams{
totalCount
}
}"
},
tokenSource.Token
)
);
}
public void Dispose()
{
_client?.Dispose();
}
}