diff --git a/Directory.Packages.props b/Directory.Packages.props index b7c44146..3a60fecb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,7 +21,6 @@ - @@ -33,4 +32,4 @@ - \ No newline at end of file + diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/GraphQLClientExceptionHandling.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/GraphQLClientExceptionHandling.cs index de6a4286..0c5b70f5 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/GraphQLClientExceptionHandling.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/GraphQLClientExceptionHandling.cs @@ -1,7 +1,8 @@ using System.ComponentModel; +using FluentAssertions; using GraphQL; using GraphQL.Client.Http; -using Shouldly; + using Speckle.Newtonsoft.Json; using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Inputs; diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs index 617257e9..271ac703 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ActiveUserResourceTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; @@ -29,7 +29,7 @@ public Task DisposeAsync() public async Task ActiveUserGet() { var res = await Sut.Get(); - res.ShouldNotBeNull(); + res.Should().NotBeNull(); res!.id.Should().Be(_testUser.Account.userInfo.id); } @@ -49,7 +49,7 @@ public async Task ActiveUserUpdate() var res = await Sut.Update(new UserUpdateInput(name: NEW_NAME, bio: NEW_BIO, company: NEW_COMPANY)); - res.ShouldNotBeNull(); + res.Should().NotBeNull(); res.id.Should().Be(_testUser.Account.userInfo.id); res.name.Should().Be(NEW_NAME); res.company.Should().Be(NEW_COMPANY); @@ -64,14 +64,14 @@ public async Task ActiveUserGetProjects() var res = await Sut.GetProjects(); - res.items.ShouldContain(x => x.id == p1.id); - res.items.ShouldContain(x => x.id == p2.id); + res.items.Should().Contain(x => x.id == p1.id); + res.items.Should().Contain(x => x.id == p2.id); res.items.Count.Should().Be(2); } [Fact] public async Task ActiveUserGetProjects_NoAuth() { - await Should.ThrowAsync(async () => await Fixtures.Unauthed.ActiveUser.GetProjects()); + await FluentActions.Invoking(async () => await Fixtures.Unauthed.ActiveUser.GetProjects()).Should().ThrowAsync(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/CommentResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/CommentResourceTests.cs index ed20057e..0ebf4fb0 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/CommentResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/CommentResourceTests.cs @@ -1,4 +1,5 @@ -using Shouldly; +using FluentAssertions; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; @@ -34,7 +35,7 @@ public async Task Get() { var comment = await Sut.Get(_comment.id, _project.id); - comment.ShouldNotBeNull(); + comment.Should().NotBeNull(); comment.id.Should().Be(_comment.id); comment.authorId.Should().Be(_testUser.Account.userInfo.id); } @@ -44,19 +45,17 @@ public async Task GetProjectComments() { var comments = await Sut.GetProjectComments(_project.id); - comments.ShouldNotBeNull(); + comments.Should().NotBeNull(); comments.items.Count.Should().Be(1); comments.totalCount.Should().Be(1); Comment comment = comments.items[0]; - comment.ShouldNotBeNull(); + comment.Should().NotBeNull(); comment.authorId.Should().Be(_testUser.Account.userInfo.id); - comment.ShouldSatisfyAllConditions( - () => comment.id.Should().Be(_comment.id), - () => comment.authorId.Should().Be(_comment.authorId), - () => comment.archived.Should().Be(false), - () => comment.createdAt.Should().Be(_comment.createdAt) - ); + comment.id.Should().Be(_comment.id); +comment.authorId.Should().Be(_comment.authorId); + comment.archived.Should().Be(false); + comment.createdAt.Should().Be(_comment.createdAt); } [Fact] @@ -65,7 +64,7 @@ public async Task MarkViewed() await Sut.MarkViewed(new(_comment.id, _project.id)); var res = await Sut.Get(_comment.id, _project.id); - res.viewedAt.ShouldNotBeNull(); + res.viewedAt.Should().NotBeNull(); } [Fact] @@ -91,13 +90,11 @@ public async Task Edit() var editedComment = await Sut.Edit(input); - editedComment.ShouldNotBeNull(); - editedComment.ShouldSatisfyAllConditions( - () => editedComment.id.Should().Be(_comment.id), - () => editedComment.authorId.Should().Be(_comment.authorId), - () => editedComment.createdAt.Should().Be(_comment.createdAt), - () => editedComment.updatedAt.Should().BeGreaterThanOrEqualTo(_comment.updatedAt) - ); + editedComment.Should().NotBeNull(); + editedComment.id.Should().Be(_comment.id); + editedComment.authorId.Should().Be(_comment.authorId); + editedComment.createdAt.Should().Be(_comment.createdAt); + editedComment.updatedAt.Should().BeOnOrAfter(_comment.updatedAt); } [Fact] @@ -109,7 +106,7 @@ public async Task Reply() var editedComment = await Sut.Reply(input); - editedComment.ShouldNotBeNull(); + editedComment.Should().NotBeNull(); } private async Task CreateComment() diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceExceptionalTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceExceptionalTests.cs index 822fcb6e..a6655442 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceExceptionalTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceExceptionalTests.cs @@ -1,4 +1,5 @@ -using Shouldly; + +using FluentAssertions; using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Enums; using Speckle.Sdk.Api.GraphQL.Inputs; @@ -34,42 +35,36 @@ public async Task ModelCreate_Throws_InvalidInput(string name) CreateModelInput input = new(name, null, _project.id); // Act & Assert - var ex = await Should.ThrowAsync(async () => await Sut.Create(input)); + var ex = await FluentActions.Invoking(async () => await Sut.Create(input)).Should().ThrowAsync(); - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + ex.WithInnerExceptionExactly(); } [Fact] public async Task ModelGet_Throws_NoAuth() { // Act & Assert - var ex = await Should.ThrowAsync( + var ex = await FluentActions.Invoking( async () => await Fixtures.Unauthed.Model.Get(_model.id, _project.id) - ); + ).Should().ThrowAsync(); - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + ex.WithInnerExceptionExactly(); } [Fact] public async Task ModelGet_Throws_NonExistentModel() { // Act & Assert - var ex = await Should.ThrowAsync(async () => await Sut.Get("non existent model", _project.id)); - - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + var ex = await FluentActions.Invoking(async () => await Sut.Get("non existent model", _project.id)).Should().ThrowAsync(); + ex.WithInnerExceptionExactly(); } [Fact] public async Task ModelGet_Throws_NonExistentProject() { // Act & Assert - var ex = await Should.ThrowAsync(async () => await Sut.Get(_model.id, "non existent project")); - - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + var ex = await FluentActions.Invoking(async () => await Sut.Get(_model.id, "non existent project")).Should().ThrowAsync(); + ex.WithInnerExceptionExactly(); } [Fact] @@ -79,10 +74,8 @@ public async Task ModelUpdate_Throws_NonExistentModel() UpdateModelInput input = new("non-existent model", "MY new name", "MY new desc", _project.id); // Act & Assert - var ex = await Should.ThrowAsync(async () => await Sut.Update(input)); - - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + var ex = await FluentActions.Invoking(async () => await Sut.Update(input)).Should().ThrowAsync(); + ex.WithInnerExceptionExactly(); } [Fact] @@ -92,10 +85,8 @@ public async Task ModelUpdate_Throws_NonExistentProject() UpdateModelInput input = new(_model.id, "MY new name", "MY new desc", "non-existent project"); // Act & Assert - var ex = await Should.ThrowAsync(async () => await Sut.Update(input)); - - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + var ex = await FluentActions.Invoking(async () => await Sut.Update(input)).Should().ThrowAsync(); + ex.WithInnerExceptionExactly(); } [Fact] @@ -105,10 +96,8 @@ public async Task ModelUpdate_Throws_NonAuthProject() UpdateModelInput input = new(_model.id, "MY new name", "MY new desc", _project.id); // Act & Assert - var ex = await Should.ThrowAsync(async () => await Fixtures.Unauthed.Model.Update(input)); - - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + var ex = await FluentActions.Invoking(async () => await Fixtures.Unauthed.Model.Update(input)).Should().ThrowAsync(); + ex.WithInnerExceptionExactly(); } [Fact] @@ -121,9 +110,7 @@ public async Task ModelDelete_Throws_NoAuth() await Sut.Delete(input); // Act & Assert - var ex = await Should.ThrowAsync(async () => await Sut.Delete(input)); - - ex.InnerExceptions.ShouldHaveSingleItem(); - ex.InnerExceptions[0].Should().BeOfType(); + var ex = await FluentActions.Invoking(async () => await Sut.Delete(input)).Should().ThrowAsync(); + ex.WithInnerExceptionExactly(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs index 7292c9bf..337f4ce7 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ModelResourceTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; @@ -41,8 +41,8 @@ public async Task ModelCreate(string name, string? description) Model result = await Sut.Create(input); // Assert - result.ShouldNotBeNull(); - result.id.ShouldNotBeNull(); + result.Should().NotBeNull(); + result.id.Should().NotBeNull(); result.name.Should().ContainEquivalentOf(input.name); result.description.Should().Be(input.description); } @@ -115,13 +115,11 @@ public async Task ModelDelete() await Sut.Delete(input); // Assert: Ensure fetching the deleted model throws an exception - var getEx = await Should.ThrowAsync(() => Sut.Get(_model.id, _project.id)); - getEx.InnerExceptions.ShouldHaveSingleItem(); - getEx.InnerExceptions[0].Should().BeOfType(); + var getEx = await FluentActions.Invoking(() => Sut.Get(_model.id, _project.id)).Should().ThrowAsync(); + getEx.WithInnerExceptionExactly(); // Assert: Ensure deleting the non-existing model again throws an exception - var delEx = await Should.ThrowAsync(() => Sut.Delete(input)); - delEx.InnerExceptions.ShouldHaveSingleItem(); - delEx.InnerExceptions[0].Should().BeOfType(); + var delEx = await FluentActions.Invoking(() => Sut.Delete(input)).Should().ThrowAsync(); + getEx.WithInnerExceptionExactly(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/OtherUserResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/OtherUserResourceTests.cs index 64a76c3c..7ecdd2e0 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/OtherUserResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/OtherUserResourceTests.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Shouldly; +using FluentAssertions; using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Resources; using Speckle.Sdk.Credentials; @@ -24,7 +24,7 @@ public async Task OtherUserGet_Should_ReturnCorrectUser() { var res = await Sut.Get(_testData.userInfo.id); - res.ShouldNotBeNull(); + res.Should().NotBeNull(); res!.name.Should().Be(_testData.userInfo.name); } @@ -41,7 +41,7 @@ public async Task UserSearch_Should_ReturnMatchingUser() { var res = await Sut.UserSearch(_testData.userInfo.email, 25); - res.items.ShouldHaveSingleItem(); + res.items.Should().ContainSingle(); res.items[0].id.Should().Be(_testData.userInfo.id); } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceExceptionalTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceExceptionalTests.cs index 05f457e6..f729a9af 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceExceptionalTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceExceptionalTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; @@ -36,12 +36,11 @@ public async Task ProjectInviteCreate_InvalidInput_ShouldThrowSpeckleGraphQLExce { var input = new ProjectInviteCreateInput(email, role, serverRole, userId); - var exception = await Should.ThrowAsync(async () => + var exception = await FluentActions.Invoking(async () => { await Sut.Create(_project.id, input); - }); + }).Should().ThrowAsync(); - exception.InnerExceptions.Should().ContainSingle(); - exception.InnerExceptions[0].Should().BeOfType(); + exception.WithInnerExceptionExactly(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs index 35ed2ceb..6b8a7914 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectInviteResourceTests.cs @@ -1,6 +1,6 @@ using System.Linq; using System.Threading.Tasks; -using Shouldly; +using FluentAssertions; using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL; using Speckle.Sdk.Api.GraphQL.Inputs; @@ -46,9 +46,9 @@ public async Task ProjectInviteCreate_ByEmail() var invite = invites.First(i => i.projectId == res.id); res.id.Should().Be(_project.id); - res.invitedTeam.ShouldHaveSingleItem(); + res.invitedTeam.Should().ContainSingle(); invite.user!.id.Should().Be(_invitee.Account.userInfo.id); - invite.token.ShouldNotBeNull(); + invite.token.Should().NotBeNull(); } [Fact] @@ -58,7 +58,7 @@ public async Task ProjectInviteCreate_ByUserId() var res = await _inviter.ProjectInvite.Create(_project.id, input); res.id.Should().Be(_project.id); - res.invitedTeam.ShouldHaveSingleItem(); + res.invitedTeam.Should().ContainSingle(); res.invitedTeam[0].user!.id.Should().Be(_invitee.Account.userInfo.id); } @@ -67,10 +67,8 @@ public async Task ProjectInviteGet() { var collaborator = await _invitee.ProjectInvite.Get(_project.id, _createdInvite.token).NotNull(); - collaborator.ShouldSatisfyAllConditions( - () => collaborator.inviteId.Should().Be(_createdInvite.inviteId), - () => collaborator.user!.id.Should().Be(_createdInvite.user!.id) - ); + collaborator.inviteId.Should().Be(_createdInvite.inviteId); + collaborator.user!.id.Should().Be(_createdInvite.user!.id); } [Fact] @@ -90,7 +88,7 @@ public async Task ProjectInviteUse_MemberAdded() var teamMembers = project.team.Select(c => c.user.id).ToArray(); var expectedTeamMembers = new[] { _inviter.Account.userInfo.id, _invitee.Account.userInfo.id }; - teamMembers.Should().Be(expectedTeamMembers, ignoreOrder: true); + teamMembers.Should().BeEquivalentTo(expectedTeamMembers); } [Fact] diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceExceptionalTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceExceptionalTests.cs index ad7ca433..47ab0faf 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceExceptionalTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceExceptionalTests.cs @@ -1,4 +1,5 @@ -using Shouldly; + +using FluentAssertions; using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL; using Speckle.Sdk.Api.GraphQL.Enums; diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceTests.cs index 87acbcd9..8c28f3fa 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/ProjectResourceTests.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Enums; using Speckle.Sdk.Api.GraphQL.Inputs; @@ -47,11 +47,11 @@ ProjectVisibility visibility var result = await Sut.Create(input); // Assert - result.ShouldNotBeNull(); - result.id.ShouldNotBeNullOrWhiteSpace(); + result.Should().NotBeNull(); + result.id.Should().NotBeNullOrWhiteSpace(); result.name.Should().Be(input.name); result.description.Should().Be(input.description ?? string.Empty); - result.visibility.Should().Be(input.visibility.ShouldNotBeNull()); + input.visibility.Should().NotBeNull(); } [Fact] @@ -98,9 +98,8 @@ public async Task ProjectDelete_Should_DeleteProjectSuccessfully() await Sut.Delete(toDelete.id); // Assert - var exception = await Should.ThrowAsync( + await FluentActions.Invoking( async () => await Sut.Get(toDelete.id) - ); - exception.ShouldNotBeNull(); + ).Should().ThrowAsync(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs index 3366c33f..8ad940c6 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/SubscriptionResourceTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Enums; using Speckle.Sdk.Api.GraphQL.Inputs; @@ -47,10 +47,10 @@ public async Task UserProjectsUpdated_SubscriptionIsCalled() await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered - subscriptionMessage.ShouldNotBeNull(); + subscriptionMessage.Should().NotBeNull(); subscriptionMessage!.id.Should().Be(created.id); subscriptionMessage.type.Should().Be(UserProjectsUpdatedMessageType.ADDED); - subscriptionMessage.project.ShouldNotBeNull(); + subscriptionMessage.project.Should().NotBeNull(); } [Fact] @@ -68,10 +68,10 @@ public async Task ProjectModelsUpdated_SubscriptionIsCalled() await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered - subscriptionMessage.ShouldNotBeNull(); + subscriptionMessage.Should().NotBeNull(); subscriptionMessage!.id.Should().Be(created.id); subscriptionMessage.type.Should().Be(ProjectModelsUpdatedMessageType.CREATED); - subscriptionMessage.model.ShouldNotBeNull(); + subscriptionMessage.model.Should().NotBeNull(); } [Fact] @@ -89,10 +89,10 @@ public async Task ProjectUpdated_SubscriptionIsCalled() await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered - subscriptionMessage.ShouldNotBeNull(); + subscriptionMessage.Should().NotBeNull(); subscriptionMessage!.id.Should().Be(created.id); subscriptionMessage.type.Should().Be(ProjectUpdatedMessageType.UPDATED); - subscriptionMessage.project.ShouldNotBeNull(); + subscriptionMessage.project.Should().NotBeNull(); } [Fact] @@ -109,10 +109,10 @@ public async Task ProjectVersionsUpdated_SubscriptionIsCalled() await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered - subscriptionMessage.ShouldNotBeNull(); + subscriptionMessage.Should().NotBeNull(); subscriptionMessage!.id.Should().Be(created); subscriptionMessage.type.Should().Be(ProjectVersionsUpdatedMessageType.CREATED); - subscriptionMessage.version.ShouldNotBeNull(); + subscriptionMessage.version.Should().NotBeNull(); } [Fact] @@ -130,9 +130,9 @@ public async Task ProjectCommentsUpdated_SubscriptionIsCalled() await Task.Delay(WAIT_PERIOD); // Give time for subscription to be triggered - subscriptionMessage.ShouldNotBeNull(); + subscriptionMessage.Should().NotBeNull(); subscriptionMessage!.id.Should().Be(created.id); subscriptionMessage.type.Should().Be(ProjectCommentsUpdatedMessageType.CREATED); - subscriptionMessage.comment.ShouldNotBeNull(); + subscriptionMessage.comment.Should().NotBeNull(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs index b9946044..2c2b2104 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Api/GraphQL/Resources/VersionResourceTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Inputs; using Speckle.Sdk.Api.GraphQL.Models; @@ -104,10 +104,10 @@ public async Task VersionDelete() await Sut.Delete(input); - var getEx = await Should.ThrowAsync(async () => await Sut.Get(_version.id, _project.id)); - getEx.InnerExceptions.ShouldHaveSingleItem().Should().BeOfType(); + var getEx = await FluentActions.Invoking(async () => await Sut.Get(_version.id, _project.id)).Should().ThrowAsync(); + getEx.WithInnerExceptionExactly(); - var delEx = await Should.ThrowAsync(async () => await Sut.Delete(input)); - delEx.InnerExceptions.ShouldHaveSingleItem().Should().BeOfType(); + var delEx = await FluentActions.Invoking(async () => await Sut.Delete(input)).Should().ThrowAsync(); + delEx.WithInnerExceptionExactly(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs b/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs index 9a244432..58554d3f 100644 --- a/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/Credentials/UserServerInfoTests.cs @@ -2,7 +2,7 @@ using FluentAssertions; using GraphQL.Client.Http; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Credentials; using Xunit; @@ -27,7 +27,7 @@ public async Task IsFrontEnd2True() .ServiceProvider.GetRequiredService() .GetServerInfo(new("https://app.speckle.systems/")); - result.ShouldNotBeNull(); + result.Should().NotBeNull(); result.frontend2.Should().BeTrue(); } @@ -38,7 +38,7 @@ public async Task IsFrontEnd2False() .ServiceProvider.GetRequiredService() .GetServerInfo(new("https://speckle.xyz/")); - result.ShouldNotBeNull(); + result.Should().NotBeNull(); result.frontend2.Should().BeFalse(); } @@ -53,9 +53,9 @@ public async Task GetServerInfo_ExpectFail_CantPing() { Uri serverUrl = new(_acc.serverInfo.url); - await Should.ThrowAsync( + await FluentActions.Invoking( async () => await Fixtures.ServiceProvider.GetRequiredService().GetServerInfo(serverUrl) - ); + ).Should().ThrowAsync(); } [Fact] @@ -63,9 +63,9 @@ public async Task GetServerInfo_ExpectFail_NoServer() { Uri serverUrl = new("http://invalidserver.local"); - await Should.ThrowAsync( + await FluentActions.Invoking( async () => await Fixtures.ServiceProvider.GetRequiredService().GetServerInfo(serverUrl) - ); + ).Should().ThrowAsync(); } [Fact] @@ -88,21 +88,21 @@ public async Task GetUserInfo_ExpectFail_NoServer() { Uri serverUrl = new("http://invalidserver.local"); - await Should.ThrowAsync( + await FluentActions.Invoking( async () => await Fixtures.ServiceProvider.GetRequiredService().GetUserInfo("", serverUrl) - ); + ).Should().ThrowAsync(); } [Fact] public async Task GetUserInfo_ExpectFail_NoUser() { Uri serverUrl = new(_acc.serverInfo.url); + await FluentActions.Invoking( - await Should.ThrowAsync( async () => await Fixtures .ServiceProvider.GetRequiredService() .GetUserInfo("Bearer 08913c3c1e7ac65d779d1e1f11b942a44ad9672ca9", serverUrl) - ); + ).Should().ThrowAsync(); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/MemoryTransportTests.cs b/tests/Speckle.Sdk.Tests.Integration/MemoryTransportTests.cs index 585c027c..cc5c4bd6 100644 --- a/tests/Speckle.Sdk.Tests.Integration/MemoryTransportTests.cs +++ b/tests/Speckle.Sdk.Tests.Integration/MemoryTransportTests.cs @@ -2,7 +2,7 @@ using System.Reflection; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Host; using Speckle.Sdk.Models; @@ -63,15 +63,15 @@ public async Task SendAndReceiveObjectWithBlobs() blobPaths.Count.Should().Be(3); var objectBlobs = receivedObject["blobs"] as IList; - objectBlobs.ShouldNotBeNull(); + objectBlobs.Should().NotBeNull(); - var blobs = objectBlobs.Cast().ToList(); + var blobs = objectBlobs!.Cast().ToList(); // Check that we have three blobs blobs.Count.Should().Be(3); // Check that received blobs point to local path (where they were received) - blobs[0].filePath.ShouldContain(_memoryTransport.BlobStorageFolder); - blobs[1].filePath.ShouldContain(_memoryTransport.BlobStorageFolder); - blobs[2].filePath.ShouldContain(_memoryTransport.BlobStorageFolder); + blobs[0].filePath.Should().Contain(_memoryTransport.BlobStorageFolder); + blobs[1].filePath.Should().Contain(_memoryTransport.BlobStorageFolder); + blobs[2].filePath.Should().Contain(_memoryTransport.BlobStorageFolder); } } diff --git a/tests/Speckle.Sdk.Tests.Integration/Usings.cs b/tests/Speckle.Sdk.Tests.Integration/Usings.cs deleted file mode 100644 index 32445676..00000000 --- a/tests/Speckle.Sdk.Tests.Integration/Usings.cs +++ /dev/null @@ -1 +0,0 @@ -global using NUnit.Framework; diff --git a/tests/Speckle.Sdk.Tests.Integration/packages.lock.json b/tests/Speckle.Sdk.Tests.Integration/packages.lock.json index 38079a98..a9b77714 100644 --- a/tests/Speckle.Sdk.Tests.Integration/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Integration/packages.lock.json @@ -63,20 +63,6 @@ "resolved": "2.8.2", "contentHash": "vm1tbfXhFmjFMUmS4M0J0ASXz3/U5XvXBa6DOQUL3fEz4Vt6YPhv+ESCarx6M6D+9kJkJYZKCNvJMas1+nVfmQ==" }, - "DiffEngine": { - "type": "Transitive", - "resolved": "11.3.0", - "contentHash": "k0ZgZqd09jLZQjR8FyQbSQE86Q7QZnjEzq1LPHtj1R2AoWO8sjV5x+jlSisL7NZAbUOI4y+7Bog8gkr9WIRBGw==", - "dependencies": { - "EmptyFiles": "4.4.0", - "System.Management": "6.0.1" - } - }, - "EmptyFiles": { - "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "gwJEfIGS7FhykvtZoscwXj/XwW+mJY6UbAZk+qtLKFUGWC95kfKXnj8VkxsZQnWBxJemM/q664rGLN5nf+OHZw==" - }, "GraphQL.Client.Abstractions": { "type": "Transitive", "resolved": "6.0.0", @@ -226,11 +212,6 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "System.CodeDom": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "CPc6tWO1LAer3IzfZufDBRL+UZQcj5uS207NHALQzP84Vp/z6wF0Aa0YZImOQY8iStY0A2zI/e3ihKNPfUm8XA==" - }, "System.ComponentModel.Annotations": { "type": "Transitive", "resolved": "4.5.0", @@ -253,14 +234,6 @@ "Microsoft.Win32.SystemEvents": "6.0.0" } }, - "System.Management": { - "type": "Transitive", - "resolved": "6.0.1", - "contentHash": "10J1D0h/lioojphfJ4Fuh5ZUThT/xOVHdV9roGBittKKNP2PMjrvibEdbVTGZcPra1399Ja3tqIJLyQrc5Wmhg==", - "dependencies": { - "System.CodeDom": "6.0.0" - } - }, "System.Memory": { "type": "Transitive", "resolved": "4.5.3", @@ -370,7 +343,6 @@ "FluentAssertions": "[7.0.0, )", "Microsoft.Extensions.DependencyInjection": "[2.2.0, )", "Microsoft.NET.Test.Sdk": "[17.11.1, )", - "Shouldly": "[4.2.1, )", "Speckle.DoubleNumerics": "[4.0.1, )", "Speckle.Sdk": "[1.0.0, )", "altcover": "[8.9.3, )", @@ -441,16 +413,6 @@ "Microsoft.Extensions.Options": "2.2.0" } }, - "Shouldly": { - "type": "CentralTransitive", - "requested": "[4.2.1, )", - "resolved": "4.2.1", - "contentHash": "dKAKiSuhLKqD2TXwLKtqNg1nwzJcIKOOMncZjk9LYe4W+h+SCftpWdxwR79YZUIHMH+3Vu9s0s0UHNrgICLwRQ==", - "dependencies": { - "DiffEngine": "11.3.0", - "EmptyFiles": "4.4.0" - } - }, "Speckle.DoubleNumerics": { "type": "CentralTransitive", "requested": "[4.0.1, )", diff --git a/tests/Speckle.Sdk.Tests.Unit/Api/ClientResiliencyPolicyTest.cs b/tests/Speckle.Sdk.Tests.Unit/Api/ClientResiliencyPolicyTest.cs index 51db8e92..bc44c254 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Api/ClientResiliencyPolicyTest.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Api/ClientResiliencyPolicyTest.cs @@ -2,8 +2,8 @@ using FluentAssertions; using GraphQL; using Microsoft.Extensions.DependencyInjection; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Credentials; diff --git a/tests/Speckle.Sdk.Tests.Unit/Api/GraphQLErrorHandler.cs b/tests/Speckle.Sdk.Tests.Unit/Api/GraphQLErrorHandler.cs index 59924769..a04e1db6 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Api/GraphQLErrorHandler.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Api/GraphQLErrorHandler.cs @@ -1,7 +1,7 @@ using FluentAssertions; using GraphQL; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/ClosureTests.cs b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/ClosureTests.cs index 4e12bc4d..c4476eb9 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/ClosureTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/ClosureTests.cs @@ -1,8 +1,8 @@ using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Api; using Speckle.Sdk.Common; using Speckle.Sdk.Host; diff --git a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendObjectReferences.cs b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendObjectReferences.cs index 3630f472..f88a1a52 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendObjectReferences.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendObjectReferences.cs @@ -1,7 +1,7 @@ using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Api; using Speckle.Sdk.Host; using Speckle.Sdk.Models; @@ -32,7 +32,7 @@ public async Task SendObjectsWithApplicationIds(int testDepth) MemoryTransport transport = new(); var result = await _operations.Send(testData, [transport]); - result.rootObjId.ShouldNotBeNull(); + result.rootObjId.Should().NotBeNull(); result.rootObjId.Length.Should().Be(32); @@ -49,7 +49,7 @@ public async Task SendObjectsWithoutApplicationIds(int testDepth) MemoryTransport transport = new(); var result = await _operations.Send(testData, [transport]); - result.rootObjId.ShouldNotBeNull(); + result.rootObjId.Should().NotBeNull(); result.rootObjId.Length.Should().Be(32); diff --git a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendReceiveLocal.cs b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendReceiveLocal.cs index 3cdbd54d..69dca463 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendReceiveLocal.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SendReceiveLocal.cs @@ -1,7 +1,7 @@ using System.Collections.Concurrent; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Common; using Speckle.Sdk.Host; @@ -51,7 +51,7 @@ public async Task LocalUploadAndDownload() using SQLiteTransport localTransport = new(); (var objId01, var references) = await _operations.Send(myObject, localTransport, false); - objId01.ShouldNotBeNull(); + objId01.Should().NotBeNull(); references.Count.Should().Be(NUM_OBJECTS); var commitPulled = await _operations.Receive(objId01.NotNull()); @@ -79,7 +79,7 @@ public async Task LocalUploadDownload() var commitPulled = await _operations.Receive(objId01); List items = (List)commitPulled["@items"].NotNull(); - items.ShouldAllBe(x => x is Point); + items.Should().AllSatisfy(x => x.Should().BeOfType()); items.Count.Should().Be(NUM_OBJECTS); } @@ -100,7 +100,7 @@ public async Task LocalUploadDownloadSmall() (var objId01, _) = await _operations.Send(myObject, _sut, false); - objId01.ShouldNotBeNull(); + objId01.Should().NotBeNull(); var objsPulled = await _operations.Receive(objId01); ((List)objsPulled["@items"].NotNull()).Count.Should().Be(30); @@ -123,7 +123,7 @@ public async Task LocalUploadDownloadListDic() (var _objId01, _) = await _operations.Send(myObject, _sut, false); - _objId01.ShouldNotBeNull(); + _objId01.Should().NotBeNull(); var objsPulled = await _operations.Receive(_objId01); ((List)((Dictionary)objsPulled["@dictionary"].NotNull())["a"]).First().Should().Be(1); @@ -158,7 +158,7 @@ public async Task UploadDownloadNonCommitObject() (var objId01, _) = await _operations.Send(obj, _sut, false); - objId01.ShouldNotBeNull(); + objId01.Should().NotBeNull(); var objPulled = await _operations.Receive(objId01); @@ -202,7 +202,7 @@ await _operations.Receive( progress = x; }) ); - progress.ShouldNotBeNull(); + progress.Should().NotBeNull(); } [Fact(DisplayName = "Should not dispose of transports if so specified.")] diff --git a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SerializationTests.cs b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SerializationTests.cs index 9502eb44..39d006c9 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SerializationTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Api/Operations/SerializationTests.cs @@ -1,7 +1,7 @@ using System.Drawing; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Credentials; @@ -111,8 +111,8 @@ public async Task ListDynamicProp() var dsrls = await _operations.DeserializeAsync(str); var list = dsrls["test"] as List; - list.ShouldNotBeNull(); // Ensure the list isn't null in first place - list.Count.Should().Be(100); + list.Should().NotBeNull(); // Ensure the list isn't null in first place + list!.Count.Should().Be(100); } [Fact] diff --git a/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs b/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs index 353e7ea5..cf0d94f2 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Common/NotNullTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Common; using Xunit; @@ -21,7 +21,7 @@ public void Empty(string[]? test, int length) public void NotNullClass() { var t = NotNullExtensions.NotNull("test"); - t.ShouldNotBeNull().Should().Be("test"); + t.Should().NotBeNull().Should().Be("test"); } [Fact] @@ -35,7 +35,7 @@ public void NotNullStruct() public async Task NotNullClass_Task() { var t = await NotNullExtensions.NotNull(Task.FromResult("test")); - t.ShouldNotBeNull().Should().Be("test"); + t.Should().NotBeNull().Should().Be("test"); } [Fact] @@ -49,7 +49,7 @@ public async Task NotNullStruct_Task() public async Task NotNullClass_ValueTask() { var t = await NotNullExtensions.NotNull(ValueTask.FromResult("test")); - t.ShouldNotBeNull().Should().Be("test"); + t.Should().NotBeNull().Should().Be("test"); } [Fact] @@ -62,50 +62,44 @@ public async Task NotNullStruct_ValueTask() [Fact] public void NotNullClass_Exception() { - var exception = Should.Throw(() => NotNullExtensions.NotNull((string?)null)); - exception.ShouldNotBeNull(); + FluentActions.Invoking(() => NotNullExtensions.NotNull((string?)null)); } [Fact] public void NotNullStruct_Exception() { - var exception = Should.Throw(() => NotNullExtensions.NotNull((int?)null)); - exception.ShouldNotBeNull(); + FluentActions.Invoking(() => NotNullExtensions.NotNull((int?)null)); } [Fact] - public void NotNullClass_Task_Exception() + public async Task NotNullClass_Task_Exception() { - var exception = Should.ThrowAsync( + await FluentActions.Invoking( async () => await NotNullExtensions.NotNull(Task.FromResult((string?)null)) - ); - exception.ShouldNotBeNull(); + ).Should().ThrowAsync(); } [Fact] - public void NotNullStruct_Task_Exception() + public async Task NotNullStruct_Task_Exception() { - var exception = Should.ThrowAsync( + await FluentActions.Invoking( async () => await NotNullExtensions.NotNull(Task.FromResult((int?)null)) - ); - exception.ShouldNotBeNull(); + ).Should().ThrowAsync(); } [Fact] - public void NotNullClass_ValueTask_Exception() + public async Task NotNullClass_ValueTask_Exception() { - var exception = Should.ThrowAsync( + await FluentActions.Invoking( async () => await NotNullExtensions.NotNull(ValueTask.FromResult((string?)null)) - ); - exception.ShouldNotBeNull(); + ).Should().ThrowAsync(); } [Fact] - public void NotNullStruct_ValueTask_Exception() + public async Task NotNullStruct_ValueTask_Exception() { - var exception = Should.ThrowAsync( + await FluentActions.Invoking( async () => await NotNullExtensions.NotNull(ValueTask.FromResult((int?)null)) - ); - exception.ShouldNotBeNull(); + ).Should().ThrowAsync(); } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs b/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs index 41a23561..62d59a1b 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Common/UnitsTest.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Common; using Xunit; @@ -60,7 +60,7 @@ public void GetUnitsFromString_ReturnsSupported(string unit) [MemberData(nameof(NotSupportedUnitsGenerator))] public void GetUnitsFromString_ThrowsUnSupported(string unit) { - Should.Throw(() => Units.GetUnitsFromString(unit)); + FluentActions.Invoking(() => Units.GetUnitsFromString(unit)).Should().Throw(); } [Theory] diff --git a/tests/Speckle.Sdk.Tests.Unit/Credentials/AccountServerMigrationTests.cs b/tests/Speckle.Sdk.Tests.Unit/Credentials/AccountServerMigrationTests.cs index ab488c49..6859af86 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Credentials/AccountServerMigrationTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Credentials/AccountServerMigrationTests.cs @@ -1,6 +1,6 @@ using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Credentials; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Credentials/Accounts.cs b/tests/Speckle.Sdk.Tests.Unit/Credentials/Accounts.cs index 4e5436a0..a00373be 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Credentials/Accounts.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Credentials/Accounts.cs @@ -1,6 +1,6 @@ using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api.GraphQL.Models; using Speckle.Sdk.Credentials; using Xunit; @@ -73,7 +73,7 @@ public void GetAccount_ById() [Fact] public void GetAccount_ById_ThrowsWhenNotFound() { - Should.Throw(() => _accountManager.GetAccount("Non_existent_id")); + FluentActions.Invoking(() => _accountManager.GetAccount("Non_existent_id")).Should().Throw(); } public static IEnumerable TestCases() // Replaces NUnit's TestCaseSource @@ -96,7 +96,7 @@ public void GetAccountsForServer(Account target) var acc = accs[0]; - acc.ShouldNotBeSameAs(target); // We expect new objects (no reference equality) + acc.Should().NotBeSameAs(target); // We expect new objects (no reference equality) acc.serverInfo.company.Should().Be(target.serverInfo.company); acc.serverInfo.url.Should().Be(target.serverInfo.url); acc.refreshToken.Should().Be(target.refreshToken); @@ -120,7 +120,7 @@ public void EnsureLocalIdentifiers_AreUniqueAcrossServers() userInfo = new UserInfo { id = id }, }.GetLocalIdentifier(); - acc1.ShouldNotBe(acc2); + acc1.Should().NotBe(acc2); } ~CredentialInfrastructure() // Equivalent of `OneTimeTearDown` diff --git a/tests/Speckle.Sdk.Tests.Unit/Helpers/Path.cs b/tests/Speckle.Sdk.Tests.Unit/Helpers/Path.cs index af3ad64d..a4a11cfc 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Helpers/Path.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Helpers/Path.cs @@ -1,5 +1,5 @@ using System.Runtime.InteropServices; -using Shouldly; +using FluentAssertions; using Speckle.Sdk.Logging; using Xunit; @@ -38,7 +38,7 @@ public void TestUserApplicationDataPath() throw new NotImplementedException("Your OS platform is not supported"); } - userPath.ShouldMatch(pattern); + userPath.Should().Match(pattern); } [Fact] @@ -77,6 +77,6 @@ public void TestInstallApplicationDataPath() throw new NotImplementedException("Your OS platform is not supported"); } - installPath.ShouldMatch(pattern); + installPath.Should().Match(pattern); } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Host/HostApplicationTests.cs b/tests/Speckle.Sdk.Tests.Unit/Host/HostApplicationTests.cs index 2cfb127c..0f8ed1e7 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Host/HostApplicationTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Host/HostApplicationTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Host; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/BaseTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/BaseTests.cs index eaf8331b..6cc743f5 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/BaseTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/BaseTests.cs @@ -1,7 +1,7 @@ using System.Collections.Concurrent; using System.Text; using FluentAssertions; -using Shouldly; + using Speckle.Newtonsoft.Json.Linq; using Speckle.Sdk.Common; using Speckle.Sdk.Dependencies.Serialization; @@ -51,21 +51,20 @@ public void CanValidatePropNames() // Only single leading @ allowed @base["@something"] = "A"; - Should.Throw(() => + FluentActions.Invoking(() => { @base["@@@something"] = "Testing"; - }); + }).Should().Throw(); // Invalid chars: ./ - Should.Throw(() => + FluentActions.Invoking(() => { @base["some.thing"] = "Testing"; - }); - Should.Throw(() => + }).Should().Throw(); + FluentActions.Invoking(() => { @base["some/thing"] = "Testing"; - }); - + }).Should().Throw(); // Trying to change a class member value will throw exceptions. //Assert.Throws(() => { @base["speckle_type"] = "Testing"; }); //Assert.Throws(() => { @base["id"] = "Testing"; }); @@ -121,10 +120,10 @@ public void CanGetMemberNames() var dynamicProp = "dynamicProp"; @base[dynamicProp] = 123; var names = @base.GetMembers().Keys; - names.ShouldNotContain(nameof(@base.IgnoredSchemaProp)); - names.ShouldNotContain(nameof(@base.ObsoleteSchemaProp)); - names.ShouldContain(dynamicProp); - names.ShouldContain(nameof(@base.attachedProp)); + names.Should().NotContain(nameof(@base.IgnoredSchemaProp)); + names.Should().NotContain(nameof(@base.ObsoleteSchemaProp)); + names.Should().Contain(dynamicProp); + names.Should().Contain(nameof(@base.attachedProp)); } [Fact(DisplayName = "Checks that only instance properties are returned, excluding obsolete and ignored.")] @@ -134,7 +133,7 @@ public void CanGetMembers_OnlyInstance() @base["dynamicProp"] = 123; var names = @base.GetMembers(DynamicBaseMemberType.Instance).Keys; - names.ShouldContain(nameof(@base.attachedProp)); + names.Should().Contain(nameof(@base.attachedProp)); } [Fact(DisplayName = "Checks that only dynamic properties are returned")] @@ -145,7 +144,7 @@ public void CanGetMembers_OnlyDynamic() @base[dynamicProp] = 123; var names = @base.GetMembers(DynamicBaseMemberType.Dynamic).Keys; - names.ShouldContain(dynamicProp); + names.Should().Contain(dynamicProp); names.Count.Should().Be(1); } @@ -156,8 +155,8 @@ public void CanGetMembers_OnlyInstance_IncludeIgnored() @base["dynamicProp"] = 123; var names = @base.GetMembers(DynamicBaseMemberType.Instance | DynamicBaseMemberType.SchemaIgnored).Keys; - names.ShouldContain(nameof(@base.IgnoredSchemaProp)); - names.ShouldContain(nameof(@base.attachedProp)); + names.Should().Contain(nameof(@base.IgnoredSchemaProp)); + names.Should().Contain(nameof(@base.attachedProp)); } [Fact(DisplayName = "Checks that all typed properties (including obsolete ones) are returned")] @@ -167,8 +166,8 @@ public void CanGetMembers_OnlyInstance_IncludeObsolete() @base["dynamicProp"] = 123; var names = @base.GetMembers(DynamicBaseMemberType.Instance | DynamicBaseMemberType.Obsolete).Keys; - names.ShouldContain(nameof(@base.ObsoleteSchemaProp)); - names.ShouldContain(nameof(@base.attachedProp)); + names.Should().Contain(nameof(@base.ObsoleteSchemaProp)); + names.Should().Contain(nameof(@base.attachedProp)); } [Fact] @@ -179,7 +178,7 @@ public void CanGetDynamicMembers() @base[dynamicProp] = null; var names = @base.GetDynamicMemberNames(); - names.ShouldContain(dynamicProp); + names.Should().Contain(dynamicProp); @base[dynamicProp].Should().BeNull(); } diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs index 15281c22..7c1513b1 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/BaseExtensionsTests.cs @@ -1,6 +1,6 @@ using FluentAssertions; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Models.Collections; diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/DisplayValueTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/DisplayValueTests.cs index e8e6bf1f..79b795f9 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/DisplayValueTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/DisplayValueTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Models.Extensions; @@ -40,8 +40,8 @@ public void TestTryGetDisplayValue_WithValue(Base testCase) // Assert the single item matches the expected type and property var displayValue = res?[0]; - displayValue.ShouldNotBeNull(); - displayValue.applicationId.Should().Be(PAYLOAD); + displayValue.Should().NotBeNull(); + displayValue!.applicationId.Should().Be(PAYLOAD); } public static IEnumerable TestCases() diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/ExceptionTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/ExceptionTests.cs index 96312768..073338f2 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/ExceptionTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/Extensions/ExceptionTests.cs @@ -1,5 +1,5 @@ using System; -using Shouldly; +using FluentAssertions; using Speckle.Sdk.Models.Extensions; using Xunit; @@ -13,17 +13,17 @@ public void CanPrintAllInnerExceptions() // Test with a single exception var ex = new Exception("Some error"); var exMsg = ex.ToFormattedString(); - exMsg.ShouldNotBeNull(); + exMsg.Should().NotBeNull(); // Test with an inner exception var ex2 = new Exception("One or more errors occurred", ex); var ex2Msg = ex2.ToFormattedString(); - ex2Msg.ShouldNotBeNull(); + ex2Msg.Should().NotBeNull(); // Test with an aggregate exception var ex3 = new AggregateException("One or more errors occurred", ex2); var ex3Msg = ex3.ToFormattedString(); - ex3Msg.ShouldNotBeNull(); + ex3Msg.Should().NotBeNull(); } } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/GraphTraversalTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/GraphTraversalTests.cs index e148304d..54a816ed 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/GraphTraversalTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/GraphTraversalTests.cs @@ -1,6 +1,6 @@ using System.Collections; using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Models.GraphTraversal; @@ -45,11 +45,11 @@ public void Traverse_TraversesListMembers() var ret = Traverse(testCase, traverseListsRule).Select(b => b.Current).ToList(); // Assert expected members present - ret.ShouldContain(testCase); - ret.ShouldContain(expectTraverse); + ret.Should().Contain(testCase); + ret.Should().Contain(expectTraverse); // Assert unexpected members not present - ret.ShouldNotContain(expectIgnored); + ret.Should().NotContain(expectIgnored); ret.Count.Should().Be(2); } @@ -76,11 +76,11 @@ public void Traverse_TraversesDictMembers() var ret = Traverse(testCase, traverseListsRule).Select(b => b.Current).ToList(); // Assert expected members present - ret.ShouldContain(testCase); - ret.ShouldContain(expectTraverse); + ret.Should().Contain(testCase); + ret.Should().Contain(expectTraverse); // Assert unexpected members not present - ret.ShouldNotContain(expectIgnored); + ret.Should().NotContain(expectIgnored); ret.Count.Should().Be(2); } @@ -105,11 +105,11 @@ public void Traverse_TraversesDynamic() var ret = Traverse(testCase, traverseListsRule).Select(b => b.Current).ToList(); // Assert expected members present - ret.ShouldContain(testCase); + ret.Should().Contain(testCase); ret.Count(x => x == expectTraverse).Should().Be(2); // Assert unexpected members not present - ret.ShouldNotContain(expectIgnored); + ret.Should().NotContain(expectIgnored); ret.Count.Should().Be(3); } @@ -134,11 +134,11 @@ public void Traverse_ExclusiveRule() var ret = Traverse(testCase, traverseListsRule).Select(b => b.Current).ToList(); // Assert expected members present - ret.ShouldContain(testCase); + ret.Should().Contain(testCase); ret.Count(x => x == expectTraverse).Should().Be(2); // Assert unexpected members not present - ret.ShouldNotContain(expectIgnored); + ret.Should().NotContain(expectIgnored); ret.Count.Should().Be(3); } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs index 6ca37a0f..7e96a457 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/GraphTraversal/TraversalContextExtensionsTests.cs @@ -1,7 +1,7 @@ using System; using System.Linq; using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Common; using Speckle.Sdk.Models; using Speckle.Sdk.Models.Collections; diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/Hashing.cs b/tests/Speckle.Sdk.Tests.Unit/Models/Hashing.cs index 18b00e9f..22b1ba97 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/Hashing.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/Hashing.cs @@ -1,6 +1,6 @@ using System.Diagnostics; using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Tests.Unit.Host; @@ -27,7 +27,7 @@ public void HashChangeCheck_Test() ((dynamic)secondTable).testProp = "wonderful"; - secondTable.GetId().ShouldNotBe(table.GetId(), "Changing a property should alter the object ID."); + secondTable.GetId().Should().NotBe(table.GetId(), "Changing a property should alter the object ID."); } [Fact(DisplayName = "Verifies that dynamic properties with '__' prefix are ignored during hashing.")] @@ -86,6 +86,6 @@ public void DecompositionHashes_Test() var hash1 = table.GetId(); var hash2 = table.GetId(true); - hash2.ShouldNotBe(hash1, "Hash values should differ for decomposed and non-decomposed objects."); + hash2.Should().NotBe(hash1, "Hash values should differ for decomposed and non-decomposed objects."); } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/SpeckleType.cs b/tests/Speckle.Sdk.Tests.Unit/Models/SpeckleType.cs index 070a26de..f73edb6e 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/SpeckleType.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/SpeckleType.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Tests.Unit.Models.TestModels; diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/TraversalTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/TraversalTests.cs index 758e15f4..1da74cce 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/TraversalTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/TraversalTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Common; using Speckle.Sdk.Models; using Speckle.Sdk.Models.Extensions; @@ -37,9 +37,9 @@ public void TestFlattenWithBreaker() ret.Should().OnlyHaveUniqueItems(); - ret.Where(BreakRule).ShouldNotBeEmpty(); + ret.Where(BreakRule).Should().NotBeEmpty(); - ret.ShouldNotContain(x => x.id == "should have ignored me"); + ret.Should().NotContain(x => x.id == "should have ignored me"); } [Theory(DisplayName = "Tests breaking after a fixed number of items")] diff --git a/tests/Speckle.Sdk.Tests.Unit/Models/UtilitiesTests.cs b/tests/Speckle.Sdk.Tests.Unit/Models/UtilitiesTests.cs index 62a39a52..72a63324 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Models/UtilitiesTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Models/UtilitiesTests.cs @@ -1,6 +1,6 @@ using FluentAssertions; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Dependencies; using Speckle.Sdk.Helpers; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/BatchTests.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/BatchTests.cs index c556827f..d651c62e 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/BatchTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/BatchTests.cs @@ -1,6 +1,6 @@ using FluentAssertions; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Serialisation.V2.Send; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/ChunkingTests.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/ChunkingTests.cs index 0abe3906..fc570d90 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/ChunkingTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/ChunkingTests.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; using FluentAssertions; -using Shouldly; + using Speckle.Newtonsoft.Json; using Speckle.Sdk.Host; using Speckle.Sdk.Models; diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs index c40c3554..50c4feb7 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/JsonIgnoreAttributeTests.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using FluentAssertions; -using Shouldly; + using Speckle.Newtonsoft.Json; using Speckle.Sdk.Common; using Speckle.Sdk.Host; @@ -50,17 +50,17 @@ public void IgnoredProperties_NotIncludedInJson(string ignoredPayload, string ex SpeckleObjectSerializer sut = new(); var result = sut.SerializeBase(testData); - result.ShouldNotBeNull(); - result.Value.Id.ShouldNotBeNull(); + result.Should().NotBeNull(); + result!.Value.Id.Should().NotBeNull(); var jsonString = result.Value.Json.ToString(); - jsonString.ShouldNotContain(nameof(testData.ShouldBeIgnored)); - jsonString.ShouldNotContain(ignoredPayload); + jsonString.Should().NotContain(nameof(testData.ShouldBeIgnored)); + jsonString.Should().NotContain(ignoredPayload); - jsonString.ShouldContain(nameof(testData.ShouldBeIncluded)); - jsonString.ShouldContain(expectedPayload); + jsonString.Should().Contain(nameof(testData.ShouldBeIncluded)); + jsonString.Should().Contain(expectedPayload); - result.Value.Id.Value.Value.Should().Be(expectedHash); + result.Value.Id!.Value.Value.Should().Be(expectedHash); } [Theory] @@ -78,18 +78,18 @@ string expectedHash var result = sut.SerializeBase(testData); var (json, id) = result.NotNull(); - json.Value.ShouldNotBeNull(); - id.ShouldNotBeNull(); + json.Value.Should().NotBeNull(); + id.Should().NotBeNull(); - savedObjects.SaveObject(id.Value.Value.NotNull(), json.Value); + savedObjects.SaveObject(id!.Value.Value.NotNull(), json.Value); foreach ((_, string childJson) in savedObjects.Objects) { - childJson.ShouldNotContain(nameof(testData.ShouldBeIgnored)); - childJson.ShouldNotContain(ignoredPayload); + childJson.Should().NotContain(nameof(testData.ShouldBeIgnored)); + childJson.Should().NotContain(ignoredPayload); - childJson.ShouldContain(nameof(testData.ShouldBeIncluded)); - childJson.ShouldContain(expectedPayload); + childJson.Should().Contain(nameof(testData.ShouldBeIncluded)); + childJson.Should().Contain(expectedPayload); } id.Value.Value.Should().Be(expectedHash); diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/ObjectModelDeprecationTests.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/ObjectModelDeprecationTests.cs index 5d3b2343..730ce9f4 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/ObjectModelDeprecationTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/ObjectModelDeprecationTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Host; using Speckle.Sdk.Models; using Speckle.Sdk.Serialisation.Deprecated; @@ -22,7 +22,7 @@ public void TestThatTypeWithoutAttributeFails() // Record.Exception is the xUnit alternative of Assert.Throws var exception = Record.Exception(() => TypeLoader.ParseType(typeof(string))); - exception.ShouldNotBeNull(); // Shouldly assertion + exception.Should().NotBeNull(); // Shouldly assertion exception.Should().BeOfType(); // Ensure it's the correct exception type } diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/SerializerBreakingChanges.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/SerializerBreakingChanges.cs index 29fab762..45e75f05 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/SerializerBreakingChanges.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/SerializerBreakingChanges.cs @@ -1,5 +1,6 @@ +using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using Shouldly; + using Speckle.Sdk.Api; using Speckle.Sdk.Host; using Speckle.Sdk.Models; @@ -29,36 +30,35 @@ public SerializerBreakingChanges() } [Fact] - public void StringToInt_ShouldThrow() + public async Task StringToInt_ShouldThrow() { var from = new StringValueMock { value = "testValue" }; - // xUnit + Shouldly version of Assert.ThrowsAsync - Should.ThrowAsync( + await FluentActions.Invoking( async () => await from.SerializeAsTAndDeserialize(_operations) - ); + ).Should().ThrowAsync(); } [Theory] [MemberData(nameof(MyEnums))] // Replaces [TestCaseSource(nameof(MyEnums))] - public void StringToEnum_ShouldThrow(MyEnum testCase) + public async Task StringToEnum_ShouldThrow(MyEnum testCase) { var from = new StringValueMock { value = testCase.ToString() }; - Should.ThrowAsync( + await FluentActions.Invoking( async () => await from.SerializeAsTAndDeserialize(_operations) - ); + ).Should().ThrowAsync(); } [Theory(DisplayName = "Deserialization of a JTokenType.Float to a .NET short/int/long should throw exception")] [MemberData(nameof(Float64TestCases))] [InlineData(1e+30)] // Inline test case replaces [TestCase(1e+30)] - public void DoubleToInt_ShouldThrow(double testCase) + public async Task DoubleToInt_ShouldThrow(double testCase) { var from = new DoubleValueMock { value = testCase }; - Should.ThrowAsync( + await FluentActions.Invoking( async () => await from.SerializeAsTAndDeserialize(_operations) - ); + ).Should().ThrowAsync(); } } diff --git a/tests/Speckle.Sdk.Tests.Unit/Serialisation/SimpleRoundTripTests.cs b/tests/Speckle.Sdk.Tests.Unit/Serialisation/SimpleRoundTripTests.cs index 10f4ede4..9921b254 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Serialisation/SimpleRoundTripTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Serialisation/SimpleRoundTripTests.cs @@ -1,8 +1,8 @@ using System.Reflection; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; -using NUnit.Framework; -using Shouldly; + + using Speckle.Sdk.Api; using Speckle.Sdk.Host; using Speckle.Sdk.Models; diff --git a/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj b/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj index 8c2af447..5980c41d 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj +++ b/tests/Speckle.Sdk.Tests.Unit/Speckle.Sdk.Tests.Unit.csproj @@ -11,7 +11,6 @@ - diff --git a/tests/Speckle.Sdk.Tests.Unit/Transports/DiskTransportTests.cs b/tests/Speckle.Sdk.Tests.Unit/Transports/DiskTransportTests.cs index 9505ae4d..39767b23 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Transports/DiskTransportTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Transports/DiskTransportTests.cs @@ -1,7 +1,7 @@ using System; using System.IO; using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Common; using Speckle.Sdk.Transports; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Transports/MemoryTransportTests.cs b/tests/Speckle.Sdk.Tests.Unit/Transports/MemoryTransportTests.cs index 7cd17158..e379aabb 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Transports/MemoryTransportTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Transports/MemoryTransportTests.cs @@ -1,7 +1,7 @@ // MemoryTransportTests.cs using FluentAssertions; -using Shouldly; + using Speckle.Sdk.Common; using Speckle.Sdk.Transports; using Xunit; diff --git a/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransport2Tests.cs b/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransport2Tests.cs index c1ffbabb..18309c30 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransport2Tests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransport2Tests.cs @@ -1,7 +1,7 @@ using System.Threading.Tasks; using FluentAssertions; using Microsoft.Data.Sqlite; -using Shouldly; + using Speckle.Sdk.Common; using Speckle.Sdk.Serialisation.Utilities; using Speckle.Sdk.Transports; @@ -115,11 +115,10 @@ public void UpdateObject_WhileEnumerating() _sqlite.UpdateObject(key, newData); } - // Assert objects were updated - _sqlite.GetAllObjects().ToList().ShouldAllBe(x => x!.Contains(UPDATE_STRING)); - - // Assert objects were updated only once - _sqlite.GetAllObjects().ToList().ShouldAllBe(x => x!.Length == length + UPDATE_STRING.Length); + // Assert that objects were updated + _sqlite.GetAllObjects().ToList().Should().AllSatisfy(o => o.Should().Contain(UPDATE_STRING)); + // Assert that objects were only updated once + _sqlite.GetAllObjects().ToList().Should().AllSatisfy(o => o.Should().HaveLength(length + UPDATE_STRING.Length)); } [Theory(DisplayName = "Tests that GetAllObjects can be called concurrently from multiple threads")] diff --git a/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransportTests.cs b/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransportTests.cs index ed5f6f6e..8a95586c 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransportTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Transports/SQLiteTransportTests.cs @@ -1,7 +1,7 @@ using System.Collections.Concurrent; using FluentAssertions; using Microsoft.Data.Sqlite; -using Shouldly; + using Speckle.Sdk.Common; using Speckle.Sdk.Transports; using Xunit; @@ -115,9 +115,9 @@ public void UpdateObject_WhileEnumerating() } // Assert that objects were updated - _sqlite.GetAllObjects().ToList().ShouldAllBe(o => o.Contains(UPDATE_STRING)); + _sqlite.GetAllObjects().ToList().Should().AllSatisfy(o => o.Should().Contain(UPDATE_STRING)); // Assert that objects were only updated once - _sqlite.GetAllObjects().ToList().ShouldAllBe(o => o.Length == length + UPDATE_STRING.Length); + _sqlite.GetAllObjects().ToList().Should().AllSatisfy(o => o.Should().HaveLength(length + UPDATE_STRING.Length)); } [Theory] diff --git a/tests/Speckle.Sdk.Tests.Unit/Transports/TransportTests.cs b/tests/Speckle.Sdk.Tests.Unit/Transports/TransportTests.cs index cca96082..c39e82e0 100644 --- a/tests/Speckle.Sdk.Tests.Unit/Transports/TransportTests.cs +++ b/tests/Speckle.Sdk.Tests.Unit/Transports/TransportTests.cs @@ -1,5 +1,5 @@ using FluentAssertions; -using Shouldly; + using Speckle.Newtonsoft.Json; using Speckle.Sdk.Common; using Speckle.Sdk.Transports; @@ -40,8 +40,8 @@ public async Task HasObject() { var preAdd = await Sut.NotNull().HasObjects(new[] { PAYLOAD_ID }); preAdd.Count.Should().Be(1); - preAdd.Values.ShouldNotContain(true); - preAdd.Keys.ShouldContain(PAYLOAD_ID); + preAdd.Values.Should().NotContain(true); + preAdd.Keys.Should().Contain(PAYLOAD_ID); } Sut.SaveObject(PAYLOAD_ID, PAYLOAD_DATA); @@ -50,8 +50,8 @@ public async Task HasObject() { var postAdd = await Sut.HasObjects(new[] { PAYLOAD_ID }); postAdd.Count.Should().Be(1); - postAdd.Values.ShouldNotContain(false); - postAdd.Keys.ShouldContain(PAYLOAD_ID); + postAdd.Values.Should().NotContain(false); + postAdd.Keys.Should().Contain(PAYLOAD_ID); } } @@ -78,7 +78,7 @@ public async Task SaveObject_ConcurrentWrites() var ids = testData.Select(x => x.id).ToList(); var hasObjectsResult = await Sut.HasObjects(ids); - hasObjectsResult.Values.ShouldNotContain(false); + hasObjectsResult.Values.Should().NotContain(false); hasObjectsResult.Keys.Should().BeEquivalentTo(ids); //Test: GetObjects @@ -93,29 +93,29 @@ public async Task SaveObject_ConcurrentWrites() public void ToString_IsNotEmpty() { var toString = Sut.NotNull().ToString(); - toString.ShouldNotBeNullOrEmpty(); + toString.Should().NotBeNullOrEmpty(); } [Fact] public void TransportName_IsNotEmpty() { var toString = Sut.NotNull().TransportName; - toString.ShouldNotBeNullOrEmpty(); + toString.Should().NotBeNullOrEmpty(); } [Fact] - public void SaveObject_ExceptionThrown_TaskIsCanceled() + public async Task SaveObject_ExceptionThrown_TaskIsCanceled() { using CancellationTokenSource tokenSource = new(); Sut.NotNull().CancellationToken = tokenSource.Token; - tokenSource.Cancel(); + await tokenSource.CancelAsync(); - Should.ThrowAsync(async () => + await FluentActions.Invoking(async () => { Sut.SaveObject("abcdef", "fake payload data"); await Sut.WriteComplete(); - }); + }).Should().ThrowAsync(); } [Fact] diff --git a/tests/Speckle.Sdk.Tests.Unit/packages.lock.json b/tests/Speckle.Sdk.Tests.Unit/packages.lock.json index f8699469..1a4bbd84 100644 --- a/tests/Speckle.Sdk.Tests.Unit/packages.lock.json +++ b/tests/Speckle.Sdk.Tests.Unit/packages.lock.json @@ -58,16 +58,6 @@ "resolved": "1.15.0", "contentHash": "FbU0El+EEjdpuIX4iDbeS7ki1uzpJPx8vbqOzEtqnl1GZeAGJfq+jCbxeJL2y0EPnUNk8dRnnqR2xnYXg9Tf+g==" }, - "Shouldly": { - "type": "Direct", - "requested": "[4.2.1, )", - "resolved": "4.2.1", - "contentHash": "dKAKiSuhLKqD2TXwLKtqNg1nwzJcIKOOMncZjk9LYe4W+h+SCftpWdxwR79YZUIHMH+3Vu9s0s0UHNrgICLwRQ==", - "dependencies": { - "DiffEngine": "11.3.0", - "EmptyFiles": "4.4.0" - } - }, "Speckle.DoubleNumerics": { "type": "Direct", "requested": "[4.0.1, )", @@ -97,20 +87,6 @@ "resolved": "2.8.2", "contentHash": "vm1tbfXhFmjFMUmS4M0J0ASXz3/U5XvXBa6DOQUL3fEz4Vt6YPhv+ESCarx6M6D+9kJkJYZKCNvJMas1+nVfmQ==" }, - "DiffEngine": { - "type": "Transitive", - "resolved": "11.3.0", - "contentHash": "k0ZgZqd09jLZQjR8FyQbSQE86Q7QZnjEzq1LPHtj1R2AoWO8sjV5x+jlSisL7NZAbUOI4y+7Bog8gkr9WIRBGw==", - "dependencies": { - "EmptyFiles": "4.4.0", - "System.Management": "6.0.1" - } - }, - "EmptyFiles": { - "type": "Transitive", - "resolved": "4.4.0", - "contentHash": "gwJEfIGS7FhykvtZoscwXj/XwW+mJY6UbAZk+qtLKFUGWC95kfKXnj8VkxsZQnWBxJemM/q664rGLN5nf+OHZw==" - }, "GraphQL.Client.Abstractions": { "type": "Transitive", "resolved": "6.0.0", @@ -260,11 +236,6 @@ "SQLitePCLRaw.core": "2.1.4" } }, - "System.CodeDom": { - "type": "Transitive", - "resolved": "6.0.0", - "contentHash": "CPc6tWO1LAer3IzfZufDBRL+UZQcj5uS207NHALQzP84Vp/z6wF0Aa0YZImOQY8iStY0A2zI/e3ihKNPfUm8XA==" - }, "System.ComponentModel.Annotations": { "type": "Transitive", "resolved": "4.5.0", @@ -287,14 +258,6 @@ "Microsoft.Win32.SystemEvents": "6.0.0" } }, - "System.Management": { - "type": "Transitive", - "resolved": "6.0.1", - "contentHash": "10J1D0h/lioojphfJ4Fuh5ZUThT/xOVHdV9roGBittKKNP2PMjrvibEdbVTGZcPra1399Ja3tqIJLyQrc5Wmhg==", - "dependencies": { - "System.CodeDom": "6.0.0" - } - }, "System.Memory": { "type": "Transitive", "resolved": "4.5.3",