From d31fc624125941e21425813c3e2c45941e63bf96 Mon Sep 17 00:00:00 2001 From: alex289 Date: Thu, 16 Jan 2025 14:01:27 +0100 Subject: [PATCH] feat: Replace FluentAssertions with Shouldy --- ...CleanArchitecture.Application.Tests.csproj | 2 +- .../Tenants/GetAllTenantsQueryHandlerTests.cs | 22 +++-- .../Tenants/GetTenantByIdQueryHandlerTests.cs | 9 +- .../Users/GetAllUsersQueryHandlerTests.cs | 22 ++--- .../Users/GetUserByIdQueryHandlerTests.cs | 10 +- .../CleanArchitecture.Domain.Tests.csproj | 2 +- .../LoginUser/LoginUserCommandHandlerTests.cs | 14 +-- .../ValidationTestBase.cs | 34 +++---- ...anArchitecture.Infrastructure.Tests.csproj | 2 +- .../DomainNotificationHandlerTests.cs | 12 +-- .../DomainNotificationTests.cs | 41 -------- .../UnitOfWorkTests.cs | 10 +- .../CleanArchitecture.IntegrationTests.csproj | 2 +- .../Controller/TenantControllerTests.cs | 62 ++++++------ .../Controller/UserControllerTests.cs | 98 +++++++++---------- .../ExternalServices/RedisTests.cs | 10 +- .../UtilityTests/AuthTests.cs | 4 +- .../UtilityTests/HealthChecksTests.cs | 6 +- .../gRPC/GetTenantsByIdsTests.cs | 10 +- .../gRPC/GetUsersByIdsTests.cs | 12 +-- .../CleanArchitecture.gRPC.Tests.csproj | 2 +- .../Tenants/GetTenantsByIdsTests.cs | 12 +-- .../Users/GetUsersByIdsTests.cs | 16 +-- 23 files changed, 189 insertions(+), 225 deletions(-) delete mode 100644 CleanArchitecture.Infrastructure.Tests/DomainNotificationTests.cs diff --git a/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj b/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj index f15ff58..6a07dfd 100644 --- a/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj +++ b/CleanArchitecture.Application.Tests/CleanArchitecture.Application.Tests.csproj @@ -9,10 +9,10 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CleanArchitecture.Application.Tests/Queries/Tenants/GetAllTenantsQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Tenants/GetAllTenantsQueryHandlerTests.cs index 69807b5..4a5449f 100644 --- a/CleanArchitecture.Application.Tests/Queries/Tenants/GetAllTenantsQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Tenants/GetAllTenantsQueryHandlerTests.cs @@ -3,7 +3,7 @@ using CleanArchitecture.Application.Queries.Tenants.GetAll; using CleanArchitecture.Application.Tests.Fixtures.Queries.Tenants; using CleanArchitecture.Application.ViewModels; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.Application.Tests.Queries.Tenants; @@ -29,11 +29,15 @@ public async Task Should_Get_Existing_Tenant() _fixture.VerifyNoDomainNotification(); - result.PageSize.Should().Be(query.PageSize); - result.Page.Should().Be(query.Page); - result.Count.Should().Be(1); + result.PageSize.ShouldBe(query.PageSize); + result.Page.ShouldBe(query.Page); + result.Count.ShouldBe(1); - tenant.Should().BeEquivalentTo(result.Items.First()); + var checkingTenant = result.Items.First(); + + tenant.Id.ShouldBe(checkingTenant.Id); + tenant.Name.ShouldBe(checkingTenant.Name); + tenant.Users.Count.ShouldBe(checkingTenant.Users.Count()); } [Fact] @@ -51,10 +55,10 @@ public async Task Should_Not_Get_Deleted_Tenant() new GetAllTenantsQuery(query, false), default); - result.PageSize.Should().Be(query.PageSize); - result.Page.Should().Be(query.Page); - result.Count.Should().Be(0); + result.PageSize.ShouldBe(query.PageSize); + result.Page.ShouldBe(query.Page); + result.Count.ShouldBe(0); - result.Items.Should().HaveCount(0); + result.Items.Count.ShouldBe(0); } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Queries/Tenants/GetTenantByIdQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Tenants/GetTenantByIdQueryHandlerTests.cs index cd3e3ea..695255b 100644 --- a/CleanArchitecture.Application.Tests/Queries/Tenants/GetTenantByIdQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Tenants/GetTenantByIdQueryHandlerTests.cs @@ -1,8 +1,9 @@ +using System.Linq; using System.Threading.Tasks; using CleanArchitecture.Application.Queries.Tenants.GetTenantById; using CleanArchitecture.Application.Tests.Fixtures.Queries.Tenants; using CleanArchitecture.Domain.Errors; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.Application.Tests.Queries.Tenants; @@ -22,7 +23,9 @@ public async Task Should_Get_Existing_Tenant() _fixture.VerifyNoDomainNotification(); - tenant.Should().BeEquivalentTo(result); + tenant.Id.ShouldBe(result!.Id); + tenant.Name.ShouldBe(result.Name); + tenant.Users.Count.ShouldBe(result.Users.Count()); } [Fact] @@ -38,6 +41,6 @@ public async Task Should_Not_Get_Deleted_Tenant() nameof(GetTenantByIdQuery), ErrorCodes.ObjectNotFound, $"Tenant with id {tenant.Id} could not be found"); - result.Should().BeNull(); + result.ShouldBeNull(); } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs index 7e00001..e9ce964 100644 --- a/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Users/GetAllUsersQueryHandlerTests.cs @@ -3,7 +3,7 @@ using CleanArchitecture.Application.Queries.Users.GetAll; using CleanArchitecture.Application.Tests.Fixtures.Queries.Users; using CleanArchitecture.Application.ViewModels; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.Application.Tests.Queries.Users; @@ -29,14 +29,14 @@ public async Task Should_Get_All_Users() _fixture.VerifyNoDomainNotification(); - result.PageSize.Should().Be(query.PageSize); - result.Page.Should().Be(query.Page); - result.Count.Should().Be(1); + result.PageSize.ShouldBe(query.PageSize); + result.Page.ShouldBe(query.Page); + result.Count.ShouldBe(1); var userViewModels = result.Items.ToArray(); - userViewModels.Should().NotBeNull(); - userViewModels.Should().ContainSingle(); - userViewModels.FirstOrDefault()!.Id.Should().Be(_fixture.ExistingUserId); + userViewModels.ShouldNotBeNull(); + userViewModels.ShouldHaveSingleItem(); + userViewModels.FirstOrDefault()!.Id.ShouldBe(_fixture.ExistingUserId); } [Fact] @@ -56,10 +56,10 @@ public async Task Should_Not_Get_Deleted_Users() _fixture.VerifyNoDomainNotification(); - result.PageSize.Should().Be(query.PageSize); - result.Page.Should().Be(query.Page); - result.Count.Should().Be(0); + result.PageSize.ShouldBe(query.PageSize); + result.Page.ShouldBe(query.Page); + result.Count.ShouldBe(0); - result.Items.Should().BeEmpty(); + result.Items.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs b/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs index 7b16b5d..1e6d2a3 100644 --- a/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs +++ b/CleanArchitecture.Application.Tests/Queries/Users/GetUserByIdQueryHandlerTests.cs @@ -3,7 +3,7 @@ using CleanArchitecture.Application.Queries.Users.GetUserById; using CleanArchitecture.Application.Tests.Fixtures.Queries.Users; using CleanArchitecture.Domain.Errors; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.Application.Tests.Queries.Users; @@ -23,8 +23,8 @@ public async Task Should_Get_Existing_User() _fixture.VerifyNoDomainNotification(); - result.Should().NotBeNull(); - result!.Id.Should().Be(_fixture.ExistingUserId); + result.ShouldNotBeNull(); + result!.Id.ShouldBe(_fixture.ExistingUserId); } [Fact] @@ -42,7 +42,7 @@ public async Task Should_Raise_Notification_For_No_User() ErrorCodes.ObjectNotFound, $"User with id {request.Id} could not be found"); - result.Should().BeNull(); + result.ShouldBeNull(); } [Fact] @@ -59,6 +59,6 @@ public async Task Should_Not_Get_Deleted_User() ErrorCodes.ObjectNotFound, $"User with id {_fixture.ExistingUserId} could not be found"); - result.Should().BeNull(); + result.ShouldBeNull(); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj b/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj index 89cc558..784c659 100644 --- a/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj +++ b/CleanArchitecture.Domain.Tests/CleanArchitecture.Domain.Tests.csproj @@ -10,9 +10,9 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs b/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs index c9cca36..97187b7 100644 --- a/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs +++ b/CleanArchitecture.Domain.Tests/CommandHandler/User/LoginUser/LoginUserCommandHandlerTests.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using CleanArchitecture.Domain.Commands.Users.LoginUser; using CleanArchitecture.Domain.Errors; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.Domain.Tests.CommandHandler.User.LoginUser; @@ -25,7 +25,7 @@ public async Task Should_Login_User() _fixture.VerifyNoDomainNotification(); - token.Should().NotBeNullOrEmpty(); + token.ShouldNotBeNullOrEmpty(); var handler = new JwtSecurityTokenHandler(); var decodedToken = handler.ReadToken(token) as JwtSecurityToken; @@ -33,17 +33,17 @@ public async Task Should_Login_User() var userIdClaim = decodedToken!.Claims .FirstOrDefault(x => string.Equals(x.Type, ClaimTypes.NameIdentifier)); - Guid.Parse(userIdClaim!.Value).Should().Be(user.Id); + Guid.Parse(userIdClaim!.Value).ShouldBe(user.Id); var userEmailClaim = decodedToken.Claims .FirstOrDefault(x => string.Equals(x.Type, ClaimTypes.Email)); - userEmailClaim!.Value.Should().Be(user.Email); + userEmailClaim!.Value.ShouldBe(user.Email); var userRoleClaim = decodedToken.Claims .FirstOrDefault(x => string.Equals(x.Type, ClaimTypes.Role)); - userRoleClaim!.Value.Should().Be(user.Role.ToString()); + userRoleClaim!.Value.ShouldBe(user.Role.ToString()); } [Fact] @@ -59,7 +59,7 @@ public async Task Should_Not_Login_User_No_User() ErrorCodes.ObjectNotFound, $"There is no user with email {command.Email}"); - token.Should().BeEmpty(); + token.ShouldBeEmpty(); } [Fact] @@ -77,6 +77,6 @@ public async Task Should_Not_Login_User_Incorrect_Password() DomainErrorCodes.User.PasswordIncorrect, "The password is incorrect"); - token.Should().BeEmpty(); + token.ShouldBeEmpty(); } } \ No newline at end of file diff --git a/CleanArchitecture.Domain.Tests/ValidationTestBase.cs b/CleanArchitecture.Domain.Tests/ValidationTestBase.cs index 37391ee..02371a9 100644 --- a/CleanArchitecture.Domain.Tests/ValidationTestBase.cs +++ b/CleanArchitecture.Domain.Tests/ValidationTestBase.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; using CleanArchitecture.Domain.Commands; -using FluentAssertions; using FluentValidation; +using Shouldly; namespace CleanArchitecture.Domain.Tests; @@ -21,8 +21,8 @@ protected void ShouldBeValid(TCommand command) { var result = _validation.Validate(command); - result.IsValid.Should().BeTrue(); - result.Errors.Should().BeEmpty(); + result.IsValid.ShouldBeTrue(); + result.Errors.ShouldBeEmpty(); } protected void ShouldHaveSingleError( @@ -31,11 +31,11 @@ protected void ShouldHaveSingleError( { var result = _validation.Validate(command); - result.IsValid.Should().BeFalse(); + result.IsValid.ShouldBeFalse(); - result.Errors.Count.Should().Be(1); + result.Errors.Count.ShouldBe(1); - result.Errors.First().ErrorCode.Should().Be(expectedCode); + result.Errors.First().ErrorCode.ShouldBe(expectedCode); } protected void ShouldHaveSingleError( @@ -45,12 +45,12 @@ protected void ShouldHaveSingleError( { var result = _validation.Validate(command); - result.IsValid.Should().BeFalse(); + result.IsValid.ShouldBeFalse(); - result.Errors.Count.Should().Be(1); + result.Errors.Count.ShouldBe(1); - result.Errors.First().ErrorCode.Should().Be(expectedCode); - result.Errors.First().ErrorMessage.Should().Be(expectedMessage); + result.Errors.First().ErrorCode.ShouldBe(expectedCode); + result.Errors.First().ErrorMessage.ShouldBe(expectedMessage); } protected void ShouldHaveExpectedErrors( @@ -59,15 +59,14 @@ protected void ShouldHaveExpectedErrors( { var result = _validation.Validate(command); - result.IsValid.Should().BeFalse(); - result.Errors.Count.Should().Be(expectedErrors.Length); + result.IsValid.ShouldBeFalse(); + result.Errors.Count.ShouldBe(expectedErrors.Length); foreach (var error in expectedErrors) { result.Errors .Count(validation => validation.ErrorCode == error.Key && validation.ErrorMessage == error.Value) - .Should() - .Be(1); + .ShouldBe(1); } } @@ -77,15 +76,14 @@ protected void ShouldHaveExpectedErrors( { var result = _validation.Validate(command); - result.IsValid.Should().BeFalse(); - result.Errors.Count.Should().Be(expectedErrors.Length); + result.IsValid.ShouldBeFalse(); + result.Errors.Count.ShouldBe(expectedErrors.Length); foreach (var error in expectedErrors) { result.Errors .Count(validation => validation.ErrorCode == error) - .Should() - .Be(1); + .ShouldBe(1); } } } \ No newline at end of file diff --git a/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj b/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj index ae82b08..9bd9daa 100644 --- a/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj +++ b/CleanArchitecture.Infrastructure.Tests/CleanArchitecture.Infrastructure.Tests.csproj @@ -9,9 +9,9 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CleanArchitecture.Infrastructure.Tests/DomainNotificationHandlerTests.cs b/CleanArchitecture.Infrastructure.Tests/DomainNotificationHandlerTests.cs index 15a24ed..4762602 100644 --- a/CleanArchitecture.Infrastructure.Tests/DomainNotificationHandlerTests.cs +++ b/CleanArchitecture.Infrastructure.Tests/DomainNotificationHandlerTests.cs @@ -1,5 +1,5 @@ using CleanArchitecture.Domain.Notifications; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.Infrastructure.Tests; @@ -10,7 +10,7 @@ public sealed class DomainNotificationHandlerTests public void Should_Create_DomainNotificationHandler_Instance() { var domainNotificationHandler = new DomainNotificationHandler(); - domainNotificationHandler.GetNotifications().Should().BeEmpty(); + domainNotificationHandler.GetNotifications().ShouldBeEmpty(); } [Fact] @@ -23,7 +23,7 @@ public void Should_Handle_DomainNotification() var domainNotification = new DomainNotification(key, value, code); var domainNotificationHandler = new DomainNotificationHandler(); domainNotificationHandler.Handle(domainNotification); - domainNotificationHandler.GetNotifications().Should().HaveCount(1); + domainNotificationHandler.GetNotifications().Count.ShouldBe(1); } [Fact] @@ -36,7 +36,7 @@ public void Should_Handle_DomainNotification_Overload() var domainNotification = new DomainNotification(key, value, code); var domainNotificationHandler = new DomainNotificationHandler(); domainNotificationHandler.Handle(domainNotification); - domainNotificationHandler.GetNotifications().Should().HaveCount(1); + domainNotificationHandler.GetNotifications().Count.ShouldBe(1); } [Fact] @@ -50,7 +50,7 @@ public void DomainNotification_HasNotifications_After_Handling_One() var domainNotificationHandler = new DomainNotificationHandler(); domainNotificationHandler.Handle(domainNotification); - domainNotificationHandler.HasNotifications().Should().BeTrue(); + domainNotificationHandler.HasNotifications().ShouldBeTrue(); } [Fact] @@ -58,6 +58,6 @@ public void DomainNotification_HasNotifications_False_Not_Handling_One() { var domainNotificationHandler = new DomainNotificationHandler(); - domainNotificationHandler.HasNotifications().Should().BeFalse(); + domainNotificationHandler.HasNotifications().ShouldBeFalse(); } } \ No newline at end of file diff --git a/CleanArchitecture.Infrastructure.Tests/DomainNotificationTests.cs b/CleanArchitecture.Infrastructure.Tests/DomainNotificationTests.cs deleted file mode 100644 index 14d90b6..0000000 --- a/CleanArchitecture.Infrastructure.Tests/DomainNotificationTests.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using CleanArchitecture.Domain.Notifications; -using FluentAssertions; -using Xunit; - -namespace CleanArchitecture.Infrastructure.Tests; - -public sealed class DomainNotificationTests -{ - [Fact] - public void Should_Create_DomainNotification_Instance() - { - const string key = "Key"; - const string value = "Value"; - const string code = "Code"; - - var domainNotification = new DomainNotification( - key, value, code); - - domainNotification.Key.Should().Be(key); - domainNotification.Value.Should().Be(value); - domainNotification.Should().NotBe(default(Guid)); - domainNotification.Code.Should().Be(code); - } - - [Fact] - public void Should_Create_DomainNotification_Overload_Instance() - { - const string key = "Key"; - const string value = "Value"; - const string code = "Code"; - - var domainNotification = new DomainNotification( - key, value, code); - - domainNotification.Key.Should().Be(key); - domainNotification.Value.Should().Be(value); - domainNotification.Code.Should().Be(code); - domainNotification.Should().NotBe(default(Guid)); - } -} \ No newline at end of file diff --git a/CleanArchitecture.Infrastructure.Tests/UnitOfWorkTests.cs b/CleanArchitecture.Infrastructure.Tests/UnitOfWorkTests.cs index 9b8abad..0382590 100644 --- a/CleanArchitecture.Infrastructure.Tests/UnitOfWorkTests.cs +++ b/CleanArchitecture.Infrastructure.Tests/UnitOfWorkTests.cs @@ -3,10 +3,10 @@ using System.Threading.Tasks; using CleanArchitecture.Infrastructure.Database; using CleanArchitecture.Infrastructure.Tests.Fixtures; -using FluentAssertions; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Logging; using NSubstitute; +using Shouldly; using Xunit; namespace CleanArchitecture.Infrastructure.Tests; @@ -26,7 +26,7 @@ public async Task Should_Commit_Async_Returns_True() var result = await unitOfWork.CommitAsync(); - result.Should().BeTrue(); + result.ShouldBeTrue(); } [Fact] @@ -44,7 +44,7 @@ public async Task Should_Commit_Async_Returns_False() var result = await unitOfWork.CommitAsync(); - result.Should().BeFalse(); + result.ShouldBeFalse(); } [Fact] @@ -59,9 +59,9 @@ public async Task Should_Throw_Exception_When_Commiting_With_DbUpdateException() .Do(_ => throw new Exception("Boom")); var unitOfWork = UnitOfWorkTestFixture.GetUnitOfWork(dbContextMock, loggerMock); - + Func throwsAction = async () => await unitOfWork.CommitAsync(); - await throwsAction.Should().ThrowAsync(); + await throwsAction.ShouldThrowAsync(); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj b/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj index abf3ed4..f1460fa 100644 --- a/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj +++ b/CleanArchitecture.IntegrationTests/CleanArchitecture.IntegrationTests.csproj @@ -9,7 +9,6 @@ - @@ -20,6 +19,7 @@ + diff --git a/CleanArchitecture.IntegrationTests/Controller/TenantControllerTests.cs b/CleanArchitecture.IntegrationTests/Controller/TenantControllerTests.cs index 79a96eb..0a632f2 100644 --- a/CleanArchitecture.IntegrationTests/Controller/TenantControllerTests.cs +++ b/CleanArchitecture.IntegrationTests/Controller/TenantControllerTests.cs @@ -6,7 +6,7 @@ using CleanArchitecture.Application.ViewModels.Tenants; using CleanArchitecture.IntegrationTests.Extensions; using CleanArchitecture.IntegrationTests.Fixtures; -using FluentAssertions; +using Shouldly; namespace CleanArchitecture.IntegrationTests.Controller; @@ -22,16 +22,16 @@ public async Task Should_Get_Tenant_By_Id() { var response = await _fixture.ServerClient.GetAsync($"/api/v1/Tenant/{_fixture.CreatedTenantId}"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); - message!.Data!.Id.Should().Be(_fixture.CreatedTenantId); - message.Data.Name.Should().Be("Test Tenant"); + message!.Data!.Id.ShouldBe(_fixture.CreatedTenantId); + message.Data.Name.ShouldBe("Test Tenant"); - message.Data.Users.Count().Should().Be(1); + message.Data.Users.Count().ShouldBe(1); } [Test, Order(1)] @@ -40,19 +40,19 @@ public async Task Should_Get_All_Tenants() var response = await _fixture.ServerClient.GetAsync( "api/v1/Tenant?searchTerm=Test&pageSize=5&page=1"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync>(); - message?.Data!.Items.Should().NotBeEmpty(); - message!.Data!.Items.Should().HaveCount(1); + message?.Data!.Items.ShouldNotBeEmpty(); + message!.Data!.Items.ShouldHaveSingleItem(); message.Data!.Items .FirstOrDefault(x => x.Id == _fixture.CreatedTenantId) - .Should().NotBeNull(); + .ShouldNotBeNull(); message.Data.Items .FirstOrDefault(x => x.Id == _fixture.CreatedTenantId)! - .Users.Count().Should().Be(1); + .Users.Count().ShouldBe(1); } [Test, Order(2)] @@ -60,11 +60,11 @@ public async Task Should_Not_Get_Deleted_Tenant_By_Id() { var response = await _fixture.ServerClient.GetAsync($"/api/v1/Tenant/{_fixture.DeletedTenantId}"); - response.StatusCode.Should().Be(HttpStatusCode.NotFound); + response.StatusCode.ShouldBe(HttpStatusCode.NotFound); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().BeNull(); + message?.Data.ShouldBeNull(); } [Test, Order(3)] @@ -73,15 +73,15 @@ public async Task Should_Get_All_Tenants_Including_Deleted() var response = await _fixture.ServerClient.GetAsync( "api/v1/Tenant?searchTerm=Test&pageSize=5&page=1&includeDeleted=true"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync>(); - message?.Data!.Items.Should().NotBeEmpty(); - message!.Data!.Items.Should().HaveCount(2); + message?.Data!.Items.ShouldNotBeEmpty(); + message!.Data!.Items.Count.ShouldBe(2); message.Data!.Items .FirstOrDefault(x => x.Id == _fixture.DeletedTenantId) - .Should().NotBeNull(); + .ShouldNotBeNull(); } [Test, Order(4)] @@ -91,7 +91,7 @@ public async Task Should_Create_Tenant() var response = await _fixture.ServerClient.PostAsJsonAsync("/api/v1/Tenant", request); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); var tenantId = message?.Data; @@ -99,14 +99,14 @@ public async Task Should_Create_Tenant() // Check if tenant exists var tenantResponse = await _fixture.ServerClient.GetAsync($"/api/v1/Tenant/{tenantId}"); - tenantResponse.StatusCode.Should().Be(HttpStatusCode.OK); + tenantResponse.StatusCode.ShouldBe(HttpStatusCode.OK); var tenantMessage = await tenantResponse.Content.ReadAsJsonAsync(); - tenantMessage?.Data.Should().NotBeNull(); + tenantMessage?.Data.ShouldNotBeNull(); - tenantMessage!.Data!.Id.Should().Be(tenantId!.Value); - tenantMessage.Data.Name.Should().Be(request.Name); + tenantMessage!.Data!.Id.ShouldBe(tenantId!.Value); + tenantMessage.Data.Name.ShouldBe(request.Name); } [Test, Order(5)] @@ -116,24 +116,24 @@ public async Task Should_Update_Tenant() var response = await _fixture.ServerClient.PutAsJsonAsync("/api/v1/Tenant", request); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeNull(); - message!.Data.Should().BeEquivalentTo(request); + message?.Data.ShouldNotBeNull(); + message!.Data.ShouldBeEquivalentTo(request); // Check if tenant is updated var tenantResponse = await _fixture.ServerClient.GetAsync($"/api/v1/Tenant/{_fixture.CreatedTenantId}"); - tenantResponse.StatusCode.Should().Be(HttpStatusCode.OK); + tenantResponse.StatusCode.ShouldBe(HttpStatusCode.OK); var tenantMessage = await response.Content.ReadAsJsonAsync(); - tenantMessage?.Data.Should().NotBeNull(); + tenantMessage?.Data.ShouldNotBeNull(); - tenantMessage!.Data!.Id.Should().Be(_fixture.CreatedTenantId); - tenantMessage.Data.Name.Should().Be(request.Name); + tenantMessage!.Data!.Id.ShouldBe(_fixture.CreatedTenantId); + tenantMessage.Data.Name.ShouldBe(request.Name); } [Test, Order(6)] @@ -141,11 +141,11 @@ public async Task Should_Delete_Tenant() { var response = await _fixture.ServerClient.DeleteAsync($"/api/v1/Tenant/{_fixture.CreatedTenantId}"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); // Check if tenant is deleted var tenantResponse = await _fixture.ServerClient.GetAsync($"/api/v1/Tenant/{_fixture.CreatedTenantId}"); - tenantResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); + tenantResponse.StatusCode.ShouldBe(HttpStatusCode.NotFound); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/Controller/UserControllerTests.cs b/CleanArchitecture.IntegrationTests/Controller/UserControllerTests.cs index 5daa08f..c6dd203 100644 --- a/CleanArchitecture.IntegrationTests/Controller/UserControllerTests.cs +++ b/CleanArchitecture.IntegrationTests/Controller/UserControllerTests.cs @@ -9,7 +9,7 @@ using CleanArchitecture.IntegrationTests.Extensions; using CleanArchitecture.IntegrationTests.Fixtures; using CleanArchitecture.IntegrationTests.Infrastructure.Auth; -using FluentAssertions; +using Shouldly; namespace CleanArchitecture.IntegrationTests.Controller; @@ -25,22 +25,22 @@ public async Task Should_Get_All_User() { var response = await _fixture.ServerClient.GetAsync("/api/v1/user"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync>(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); var content = message!.Data!.Items.ToList(); - content.Count.Should().Be(2); + content.Count.ShouldBe(2); var currentUser = content.First(x => x.Id == TestAuthenticationOptions.TestUserId); - currentUser.Role.Should().Be(UserRole.Admin); - currentUser.Email.Should().Be(TestAuthenticationOptions.Email); - currentUser.FirstName.Should().Be(TestAuthenticationOptions.FirstName); - currentUser.LastName.Should().Be(TestAuthenticationOptions.LastName); + currentUser.Role.ShouldBe(UserRole.Admin); + currentUser.Email.ShouldBe(TestAuthenticationOptions.Email); + currentUser.FirstName.ShouldBe(TestAuthenticationOptions.FirstName); + currentUser.LastName.ShouldBe(TestAuthenticationOptions.LastName); } [Test, Order(1)] @@ -48,18 +48,18 @@ public async Task Should_Get_User_By_Id() { var response = await _fixture.ServerClient.GetAsync("/api/v1/user/" + TestAuthenticationOptions.TestUserId); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); var content = message!.Data!; - content.Id.Should().Be(TestAuthenticationOptions.TestUserId); - content.Email.Should().Be(TestAuthenticationOptions.Email); - content.FirstName.Should().Be(TestAuthenticationOptions.FirstName); - content.LastName.Should().Be(TestAuthenticationOptions.LastName); + content.Id.ShouldBe(TestAuthenticationOptions.TestUserId); + content.Email.ShouldBe(TestAuthenticationOptions.Email); + content.FirstName.ShouldBe(TestAuthenticationOptions.FirstName); + content.LastName.ShouldBe(TestAuthenticationOptions.LastName); } [Test, Order(2)] @@ -67,17 +67,17 @@ public async Task Should_Get_All_User_Including_Deleted() { var response = await _fixture.ServerClient.GetAsync("/api/v1/user?includeDeleted=true"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync>(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); var content = message!.Data!.Items.ToList(); - content.Count.Should().Be(3); + content.Count.ShouldBe(3); - content.FirstOrDefault(x => x.Id == _fixture.DeletedUserId).Should().NotBeNull(); + content.FirstOrDefault(x => x.Id == _fixture.DeletedUserId).ShouldNotBeNull(); } [Test, Order(3)] @@ -85,10 +85,10 @@ public async Task Should_Not_Get_Deleted_User_By_Id() { var response = await _fixture.ServerClient.GetAsync("/api/v1/user/" + _fixture.DeletedUserId); - response.StatusCode.Should().Be(HttpStatusCode.NotFound); + response.StatusCode.ShouldBe(HttpStatusCode.NotFound); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().BeNull(); + message?.Data.ShouldBeNull(); } [Test, Order(4)] @@ -103,10 +103,10 @@ public async Task Should_Create_User() var response = await _fixture.ServerClient.PostAsJsonAsync("/api/v1/user", user); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeEmpty(); + message?.Data.ShouldNotBe(Guid.Empty); } [Test, Order(5)] @@ -118,10 +118,10 @@ public async Task Should_Login_User() var response = await _fixture.ServerClient.PostAsJsonAsync("/api/v1/user/login", user); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeEmpty(); + message?.Data.ShouldNotBeEmpty(); } [Test, Order(6)] @@ -129,18 +129,18 @@ public async Task Should_Get_The_Current_Active_Users() { var response = await _fixture.ServerClient.GetAsync("/api/v1/user/me"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); var content = message!.Data!; - content.Id.Should().Be(TestAuthenticationOptions.TestUserId); - content.Email.Should().Be(TestAuthenticationOptions.Email); - content.FirstName.Should().Be(TestAuthenticationOptions.FirstName); - content.LastName.Should().Be(TestAuthenticationOptions.LastName); + content.Id.ShouldBe(TestAuthenticationOptions.TestUserId); + content.Email.ShouldBe(TestAuthenticationOptions.Email); + content.FirstName.ShouldBe(TestAuthenticationOptions.FirstName); + content.LastName.ShouldBe(TestAuthenticationOptions.LastName); } [Test, Order(7)] @@ -156,32 +156,32 @@ public async Task Should_Update_User() var response = await _fixture.ServerClient.PutAsJsonAsync("/api/v1/user", user); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); var content = message!.Data; - content.Should().BeEquivalentTo(user); + content.ShouldBeEquivalentTo(user); // Check if user is really updated var userResponse = await _fixture.ServerClient.GetAsync("/api/v1/user/" + user.Id); - userResponse.StatusCode.Should().Be(HttpStatusCode.OK); + userResponse.StatusCode.ShouldBe(HttpStatusCode.OK); var userMessage = await userResponse.Content.ReadAsJsonAsync(); - userMessage?.Data.Should().NotBeNull(); + userMessage?.Data.ShouldNotBeNull(); var userContent = userMessage!.Data!; - userContent.Id.Should().Be(user.Id); - userContent.Email.Should().Be(user.Email); - userContent.FirstName.Should().Be(user.FirstName); - userContent.LastName.Should().Be(user.LastName); - userContent.Role.Should().Be(user.Role); + userContent.Id.ShouldBe(user.Id); + userContent.Email.ShouldBe(user.Email); + userContent.FirstName.ShouldBe(user.FirstName); + userContent.LastName.ShouldBe(user.LastName); + userContent.Role.ShouldBe(user.Role); } [Test, Order(8)] @@ -193,15 +193,15 @@ public async Task Should_Change_User_Password() var response = await _fixture.ServerClient.PostAsJsonAsync("/api/v1/user/changePassword", user); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeNull(); + message?.Data.ShouldNotBeNull(); var content = message!.Data; - content.Should().BeEquivalentTo(user); + content.ShouldBeEquivalentTo(user); // Verify the user can login with the new password var login = new LoginUserViewModel( @@ -210,11 +210,11 @@ public async Task Should_Change_User_Password() var loginResponse = await _fixture.ServerClient.PostAsJsonAsync("/api/v1/user/login", login); - loginResponse.StatusCode.Should().Be(HttpStatusCode.OK); + loginResponse.StatusCode.ShouldBe(HttpStatusCode.OK); var loginMessage = await loginResponse.Content.ReadAsJsonAsync(); - loginMessage?.Data.Should().NotBeEmpty(); + loginMessage?.Data.ShouldNotBeEmpty(); } [Test, Order(9)] @@ -222,17 +222,17 @@ public async Task Should_Delete_User() { var response = await _fixture.ServerClient.DeleteAsync("/api/v1/user/" + TestAuthenticationOptions.TestUserId); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var message = await response.Content.ReadAsJsonAsync(); - message?.Data.Should().NotBeEmpty(); + message?.Data.ShouldNotBe(Guid.Empty); var content = message!.Data; - content.Should().Be(TestAuthenticationOptions.TestUserId); + content.ShouldBe(TestAuthenticationOptions.TestUserId); var userResponse = await _fixture.ServerClient.GetAsync("/api/v1/user/" + TestAuthenticationOptions.TestUserId); - userResponse.StatusCode.Should().Be(HttpStatusCode.NotFound); + userResponse.StatusCode.ShouldBe(HttpStatusCode.NotFound); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/ExternalServices/RedisTests.cs b/CleanArchitecture.IntegrationTests/ExternalServices/RedisTests.cs index 8ead306..1193224 100644 --- a/CleanArchitecture.IntegrationTests/ExternalServices/RedisTests.cs +++ b/CleanArchitecture.IntegrationTests/ExternalServices/RedisTests.cs @@ -3,9 +3,9 @@ using CleanArchitecture.Domain; using CleanArchitecture.Domain.Entities; using CleanArchitecture.IntegrationTests.Extensions; -using FluentAssertions; using Microsoft.Extensions.Caching.Distributed; using Newtonsoft.Json; +using Shouldly; namespace CleanArchitecture.IntegrationTests.ExternalServices; @@ -21,14 +21,14 @@ public async Task Should_Get_Tenant_By_Id_And_Ensure_Cache() { var response = await _fixture.ServerClient.GetAsync($"/api/v1/Tenant/{_fixture.CreatedTenantId}"); var message = await response.Content.ReadAsJsonAsync(); - message!.Data!.Id.Should().Be(_fixture.CreatedTenantId); + message!.Data!.Id.ShouldBe(_fixture.CreatedTenantId); var json = await _fixture.DistributedCache.GetStringAsync(CacheKeyGenerator.GetEntityCacheKey(_fixture.CreatedTenantId)); - json.Should().NotBeNullOrEmpty(); + json.ShouldNotBeNullOrEmpty(); var tenant = JsonConvert.DeserializeObject(json!)!; - tenant.Should().NotBeNull(); - tenant.Id.Should().Be(_fixture.CreatedTenantId); + tenant.ShouldNotBeNull(); + tenant.Id.ShouldBe(_fixture.CreatedTenantId); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/UtilityTests/AuthTests.cs b/CleanArchitecture.IntegrationTests/UtilityTests/AuthTests.cs index e313f2c..9ff219b 100644 --- a/CleanArchitecture.IntegrationTests/UtilityTests/AuthTests.cs +++ b/CleanArchitecture.IntegrationTests/UtilityTests/AuthTests.cs @@ -1,7 +1,7 @@ using System.Net; using System.Threading.Tasks; using CleanArchitecture.IntegrationTests.Fixtures; -using FluentAssertions; +using Shouldly; namespace CleanArchitecture.IntegrationTests.UtilityTests; @@ -21,6 +21,6 @@ public sealed class AuthTests public async Task Should_Get_Unauthorized_If_Trying_To_Call_Endpoint_Without_Token(string url) { var response = await _fixture.ServerClient.GetAsync(url); - response.StatusCode.Should().Be(HttpStatusCode.Unauthorized); + response.StatusCode.ShouldBe(HttpStatusCode.Unauthorized); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/UtilityTests/HealthChecksTests.cs b/CleanArchitecture.IntegrationTests/UtilityTests/HealthChecksTests.cs index ec66a52..ce332bd 100644 --- a/CleanArchitecture.IntegrationTests/UtilityTests/HealthChecksTests.cs +++ b/CleanArchitecture.IntegrationTests/UtilityTests/HealthChecksTests.cs @@ -1,9 +1,9 @@ using System.Net; using System.Threading.Tasks; using CleanArchitecture.IntegrationTests.Fixtures; -using FluentAssertions; using Microsoft.Extensions.Diagnostics.HealthChecks; using Newtonsoft.Json.Linq; +using Shouldly; namespace CleanArchitecture.IntegrationTests.UtilityTests; @@ -18,11 +18,11 @@ public sealed class HealthChecksTests public async Task Should_Return_Healthy() { var response = await _fixture.ServerClient.GetAsync("/healthz"); - response.StatusCode.Should().Be(HttpStatusCode.OK); + response.StatusCode.ShouldBe(HttpStatusCode.OK); var content = await response.Content.ReadAsStringAsync(); var json = JObject.Parse(content); - json["status"]!.Value().Should().Be(HealthStatus.Healthy.ToString()); + json["status"]!.Value().ShouldBe(HealthStatus.Healthy.ToString()); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/gRPC/GetTenantsByIdsTests.cs b/CleanArchitecture.IntegrationTests/gRPC/GetTenantsByIdsTests.cs index 8e87d79..2f33afb 100644 --- a/CleanArchitecture.IntegrationTests/gRPC/GetTenantsByIdsTests.cs +++ b/CleanArchitecture.IntegrationTests/gRPC/GetTenantsByIdsTests.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using CleanArchitecture.IntegrationTests.Fixtures.gRPC; using CleanArchitecture.Proto.Tenants; -using FluentAssertions; +using Shouldly; namespace CleanArchitecture.IntegrationTests.gRPC; @@ -24,13 +24,13 @@ public async Task Should_Get_Tenants_By_Ids() var response = await client.GetByIdsAsync(request); - response.Tenants.Should().HaveCount(1); + response.Tenants.ShouldHaveSingleItem(); var tenant = response.Tenants.First(); var createdTenant = _fixture.CreateTenant(); - new Guid(tenant.Id).Should().Be(createdTenant.Id); - tenant.Name.Should().Be(createdTenant.Name); - tenant.DeletedAt.Should().NotBeNullOrWhiteSpace(); + new Guid(tenant.Id).ShouldBe(createdTenant.Id); + tenant.Name.ShouldBe(createdTenant.Name); + tenant.DeletedAt.ShouldNotBeNullOrWhiteSpace(); } } \ No newline at end of file diff --git a/CleanArchitecture.IntegrationTests/gRPC/GetUsersByIdsTests.cs b/CleanArchitecture.IntegrationTests/gRPC/GetUsersByIdsTests.cs index 5c91388..573be1d 100644 --- a/CleanArchitecture.IntegrationTests/gRPC/GetUsersByIdsTests.cs +++ b/CleanArchitecture.IntegrationTests/gRPC/GetUsersByIdsTests.cs @@ -2,7 +2,7 @@ using System.Threading.Tasks; using CleanArchitecture.IntegrationTests.Fixtures.gRPC; using CleanArchitecture.Proto.Users; -using FluentAssertions; +using Shouldly; namespace CleanArchitecture.IntegrationTests.gRPC; @@ -23,14 +23,14 @@ public async Task Should_Get_Users_By_Ids() var response = await client.GetByIdsAsync(request); - response.Users.Should().HaveCount(1); + response.Users.ShouldHaveSingleItem(); var user = response.Users.First(); var createdUser = _fixture.CreateUser(); - user.Email.Should().Be(createdUser.Email); - user.FirstName.Should().Be(createdUser.FirstName); - user.LastName.Should().Be(createdUser.LastName); - user.DeletedAt.Should().NotBeNullOrWhiteSpace(); + user.Email.ShouldBe(createdUser.Email); + user.FirstName.ShouldBe(createdUser.FirstName); + user.LastName.ShouldBe(createdUser.LastName); + user.DeletedAt.ShouldNotBeNullOrWhiteSpace(); } } \ No newline at end of file diff --git a/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj b/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj index 2673d9a..313efa4 100644 --- a/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj +++ b/CleanArchitecture.gRPC.Tests/CleanArchitecture.gRPC.Tests.csproj @@ -8,10 +8,10 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/CleanArchitecture.gRPC.Tests/Tenants/GetTenantsByIdsTests.cs b/CleanArchitecture.gRPC.Tests/Tenants/GetTenantsByIdsTests.cs index 61e51f5..6b350cd 100644 --- a/CleanArchitecture.gRPC.Tests/Tenants/GetTenantsByIdsTests.cs +++ b/CleanArchitecture.gRPC.Tests/Tenants/GetTenantsByIdsTests.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using CleanArchitecture.gRPC.Tests.Fixtures; using CleanArchitecture.Proto.Tenants; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.gRPC.Tests.Tenants; @@ -25,7 +25,7 @@ public async Task Should_Get_Empty_List_If_No_Ids_Are_Given() SetupRequest(Enumerable.Empty()), default!); - result.Tenants.Should().HaveCount(0); + result.Tenants.Count.ShouldBe(0); } [Fact] @@ -44,19 +44,19 @@ public async Task Should_Get_Empty_List_If_No_Ids_Are_Given() SetupRequest(ids), default!); - result.Tenants.Should().HaveCount(2); + result.Tenants.Count.ShouldBe(2); foreach (var tenant in result.Tenants) { var tenantId = Guid.Parse(tenant.Id); - tenantId.Should().NotBe(nonExistingId); + tenantId.ShouldNotBe(nonExistingId); var mockTenant = _fixture.ExistingTenants.First(t => t.Id == tenantId); - mockTenant.Should().NotBeNull(); + mockTenant.ShouldNotBeNull(); - tenant.Name.Should().Be(mockTenant.Name); + tenant.Name.ShouldBe(mockTenant.Name); } } diff --git a/CleanArchitecture.gRPC.Tests/Users/GetUsersByIdsTests.cs b/CleanArchitecture.gRPC.Tests/Users/GetUsersByIdsTests.cs index dbac281..b51ed34 100644 --- a/CleanArchitecture.gRPC.Tests/Users/GetUsersByIdsTests.cs +++ b/CleanArchitecture.gRPC.Tests/Users/GetUsersByIdsTests.cs @@ -4,7 +4,7 @@ using System.Threading.Tasks; using CleanArchitecture.gRPC.Tests.Fixtures; using CleanArchitecture.Proto.Users; -using FluentAssertions; +using Shouldly; using Xunit; namespace CleanArchitecture.gRPC.Tests.Users; @@ -25,7 +25,7 @@ public async Task Should_Get_Empty_List_If_No_Ids_Are_Given() SetupRequest(Enumerable.Empty()), default!); - result.Users.Should().HaveCount(0); + result.Users.Count.ShouldBe(0); } [Fact] @@ -44,21 +44,21 @@ public async Task Should_Get_Requested_Users() SetupRequest(ids), default!); - result.Users.Should().HaveCount(2); + result.Users.Count.ShouldBe(2); foreach (var user in result.Users) { var userId = Guid.Parse(user.Id); - userId.Should().NotBe(nonExistingId); + userId.ShouldNotBe(nonExistingId); var mockUser = _fixture.ExistingUsers.First(u => u.Id == userId); - mockUser.Should().NotBeNull(); + mockUser.ShouldNotBeNull(); - user.Email.Should().Be(mockUser.Email); - user.FirstName.Should().Be(mockUser.FirstName); - user.LastName.Should().Be(mockUser.LastName); + user.Email.ShouldBe(mockUser.Email); + user.FirstName.ShouldBe(mockUser.FirstName); + user.LastName.ShouldBe(mockUser.LastName); } }