Files
speckle-sharp-sdk/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceExceptionalTests.cs
T
Adam Hathcock 14d959834f Convert to Xunit (#196)
* xunit unit tests

* most pass with formatting

* convert objects to xunit

* remove nunit

* format

* merge fixes

* switch objects to fluent assertions

* update to fluent assertions

* more FA

* convert all to FA

* Format

* Fix tests

* formatting

* hopefully made credential test better

* Catch more specific exception

* use another more specific exception

* Fix tests

* update to xunit

* update packages
2025-01-09 15:32:28 +00:00

49 lines
1.4 KiB
C#

using FluentAssertions;
using Speckle.Sdk.Api;
using Speckle.Sdk.Api.GraphQL.Inputs;
using Speckle.Sdk.Api.GraphQL.Models;
using Speckle.Sdk.Api.GraphQL.Resources;
using Xunit;
namespace Speckle.Sdk.Tests.Integration.API.GraphQL.Resources;
public class ProjectInviteResourceExceptionalTests : IAsyncLifetime
{
private Client _testUser;
private Project _project;
private ProjectInviteResource Sut => _testUser.ProjectInvite;
// Replacing OneTimeSetUp with IAsyncLifetime's InitializeAsync
public async Task InitializeAsync()
{
_testUser = await Fixtures.SeedUserWithClient();
_project = await _testUser.Project.Create(new ProjectCreateInput("test", null, null));
}
// Implementing IAsyncLifetime's DisposeAsync (optional if no cleanup is needed)
public Task DisposeAsync() => Task.CompletedTask;
[Theory]
[InlineData(null, null, null, null)]
[InlineData(null, "something", "something", null)]
public async Task ProjectInviteCreate_InvalidInput_ShouldThrowSpeckleGraphQLException(
string? email,
string? role,
string? serverRole,
string? userId
)
{
var input = new ProjectInviteCreateInput(email, role, serverRole, userId);
var exception = await FluentActions
.Invoking(async () =>
{
await Sut.Create(_project.id, input);
})
.Should()
.ThrowAsync<AggregateException>();
exception.WithInnerExceptionExactly<SpeckleGraphQLException>();
}
}