diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 10e329c..1b9bf32 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -30,7 +30,7 @@ jobs: run: dotnet restore ${{ env.SOLUTION }} - name: Build - run: dotnet build ${{ env.SOLUTION }} -c Release --no-restore + run: dotnet build ${{ env.SOLUTION }} --no-restore - name: Test - run: dotnet test ${{env.SOLUTION }} -c Release --no-build --verbosity normal + run: dotnet test ${{env.SOLUTION }} --no-build --verbosity normal diff --git a/Directory.Packages.props b/Directory.Packages.props index a3a6442..90fd0f8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -37,8 +37,7 @@ - - \ No newline at end of file + diff --git a/TeamUp.sln b/TeamUp.sln index cc03b0f..a1b7572 100644 --- a/TeamUp.sln +++ b/TeamUp.sln @@ -30,8 +30,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamUp.ArchitectureTests", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamUp.EndToEndTests", "tests\TeamUp.EndToEndTests\TeamUp.EndToEndTests.csproj", "{63C1F34E-C706-43AC-A98B-E9530F875FFA}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamUp.PerformanceTests", "tests\TeamUp.PerformanceTests\TeamUp.PerformanceTests.csproj", "{B80B3E02-0B98-4ABA-92A9-74AEEEF76423}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TeamUp.TestsCommon", "tests\TeamUp.TestsCommon\TeamUp.TestsCommon.csproj", "{A3D136DD-571F-4B1C-83E2-9B538F85C575}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{F77B386C-FDBC-4BB4-AF07-0CF054DBDB7E}" @@ -81,10 +79,6 @@ Global {A3D136DD-571F-4B1C-83E2-9B538F85C575}.Debug|Any CPU.Build.0 = Debug|Any CPU {A3D136DD-571F-4B1C-83E2-9B538F85C575}.Release|Any CPU.ActiveCfg = Release|Any CPU {A3D136DD-571F-4B1C-83E2-9B538F85C575}.Release|Any CPU.Build.0 = Release|Any CPU - {B80B3E02-0B98-4ABA-92A9-74AEEEF76423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B80B3E02-0B98-4ABA-92A9-74AEEEF76423}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B80B3E02-0B98-4ABA-92A9-74AEEEF76423}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B80B3E02-0B98-4ABA-92A9-74AEEEF76423}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -99,7 +93,6 @@ Global {BFC0159D-37D8-494F-90A6-DA3EA05CFDEF} = {B78B958B-7250-4FEC-96F4-4FE0DE49D916} {63C1F34E-C706-43AC-A98B-E9530F875FFA} = {B78B958B-7250-4FEC-96F4-4FE0DE49D916} {A3D136DD-571F-4B1C-83E2-9B538F85C575} = {B78B958B-7250-4FEC-96F4-4FE0DE49D916} - {B80B3E02-0B98-4ABA-92A9-74AEEEF76423} = {B78B958B-7250-4FEC-96F4-4FE0DE49D916} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {2E9D991D-377D-45D8-9599-801391683CEA} diff --git a/src/TeamUp.Common/Extensions.cs b/src/TeamUp.Common/Extensions.cs deleted file mode 100644 index 7e797ff..0000000 --- a/src/TeamUp.Common/Extensions.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TeamUp.Common; - -public static class Extensions -{ - public static TResult Map(this T source, Func transform) => transform(source); -} diff --git a/tests/TeamUp.EndToEndTests/DataGenerators/BaseGenerator.cs b/tests/TeamUp.EndToEndTests/DataGenerators/BaseGenerator.cs new file mode 100644 index 0000000..e4c6ec4 --- /dev/null +++ b/tests/TeamUp.EndToEndTests/DataGenerators/BaseGenerator.cs @@ -0,0 +1,6 @@ +namespace TeamUp.EndToEndTests.DataGenerators; + +public abstract class BaseGenerator +{ + protected static Faker F => FExt.F; +} diff --git a/tests/TeamUp.TestsCommon/DataGenerators/EventGeneratorExtensions.cs b/tests/TeamUp.EndToEndTests/DataGenerators/EventGeneratorExtensions.cs similarity index 96% rename from tests/TeamUp.TestsCommon/DataGenerators/EventGeneratorExtensions.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/EventGeneratorExtensions.cs index d634454..faf6b05 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/EventGeneratorExtensions.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/EventGeneratorExtensions.cs @@ -1,6 +1,9 @@ using FluentAssertions.Extensions; -namespace TeamUp.TestsCommon.DataGenerators; +using TeamUp.Contracts.Events; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.DataGenerators; public static class EventGeneratorExtensions { diff --git a/tests/TeamUp.TestsCommon/DataGenerators/EventGenerators.cs b/tests/TeamUp.EndToEndTests/DataGenerators/EventGenerators.cs similarity index 98% rename from tests/TeamUp.TestsCommon/DataGenerators/EventGenerators.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/EventGenerators.cs index 5dcd588..e5e4216 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/EventGenerators.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/EventGenerators.cs @@ -3,7 +3,10 @@ using FluentAssertions.Extensions; -namespace TeamUp.TestsCommon.DataGenerators; +using TeamUp.Contracts.Events; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.DataGenerators; public sealed class EventGenerators : BaseGenerator { diff --git a/tests/TeamUp.TestsCommon/DataGenerators/InvalidRequest.cs b/tests/TeamUp.EndToEndTests/DataGenerators/InvalidRequest.cs similarity index 93% rename from tests/TeamUp.TestsCommon/DataGenerators/InvalidRequest.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/InvalidRequest.cs index bb98a41..f4199a6 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/InvalidRequest.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/InvalidRequest.cs @@ -1,7 +1,7 @@ using System.Linq.Expressions; using System.Reflection; -namespace TeamUp.TestsCommon.DataGenerators; +namespace TeamUp.EndToEndTests.DataGenerators; public sealed class InvalidRequest { diff --git a/tests/TeamUp.TestsCommon/DataGenerators/InvitationGenerators.cs b/tests/TeamUp.EndToEndTests/DataGenerators/InvitationGenerators.cs similarity index 94% rename from tests/TeamUp.TestsCommon/DataGenerators/InvitationGenerators.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/InvitationGenerators.cs index 0f86801..9289e35 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/InvitationGenerators.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/InvitationGenerators.cs @@ -1,6 +1,10 @@ global using InvitationGenerator = Bogus.Faker; -namespace TeamUp.TestsCommon.DataGenerators; +using TeamUp.Contracts.Invitations; +using TeamUp.Contracts.Teams; +using TeamUp.Contracts.Users; + +namespace TeamUp.EndToEndTests.DataGenerators; public sealed class InvitationGenerators : BaseGenerator { diff --git a/tests/TeamUp.TestsCommon/DataGenerators/TeamGeneratorExtensions.cs b/tests/TeamUp.EndToEndTests/DataGenerators/TeamGeneratorExtensions.cs similarity index 81% rename from tests/TeamUp.TestsCommon/DataGenerators/TeamGeneratorExtensions.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/TeamGeneratorExtensions.cs index 7866f74..a764c0a 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/TeamGeneratorExtensions.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/TeamGeneratorExtensions.cs @@ -1,6 +1,6 @@ -using TeamUp.Common; +using TeamUp.Contracts.Teams; -namespace TeamUp.TestsCommon.DataGenerators; +namespace TeamUp.EndToEndTests.DataGenerators; public static class TeamGeneratorExtensions { @@ -36,24 +36,6 @@ public static TeamGenerator WithMembers(this TeamGenerator teamGenerator, User o return teamGenerator.GetTeamGeneratorWithMembers(members, userMembersWithOwner); } - public static TeamGenerator WithRandomMembers(this TeamGenerator teamGenerator, int count, List pot) - { - count.Should().BeGreaterThan(0); - pot.Should().HaveCountGreaterThanOrEqualTo(1); - - return teamGenerator - .RuleFor(TeamGenerators.TEAM_MEMBERS_FIELD, (f, t) => f - .Make(count, index => f.PickRandom(pot) - .Map(user => TeamGenerators.TeamMember - .RuleForBackingField(tm => tm.TeamId, t.Id) - .RuleForBackingField(tm => tm.UserId, user.Id) - .RuleFor(tm => tm.Nickname, user.Name) - .RuleFor(tm => tm.Role, index == 0 ? TeamRole.Owner : TeamRole.Member) - .Generate())) - .ToHashSet() - .ToList()); - } - public static TeamGenerator WithMembers(this TeamGenerator teamGenerator, List members, params (User User, TeamRole Role)[] userMembers) { userMembers.Where(x => x.Role == TeamRole.Owner).Should().ContainSingle("team has to have exactly 1 owner"); diff --git a/tests/TeamUp.TestsCommon/DataGenerators/TeamGenerators.cs b/tests/TeamUp.EndToEndTests/DataGenerators/TeamGenerators.cs similarity index 97% rename from tests/TeamUp.TestsCommon/DataGenerators/TeamGenerators.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/TeamGenerators.cs index 28813b5..7688a46 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/TeamGenerators.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/TeamGenerators.cs @@ -1,6 +1,8 @@ global using TeamGenerator = Bogus.Faker; -namespace TeamUp.TestsCommon.DataGenerators; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.DataGenerators; public sealed class TeamGenerators : BaseGenerator { diff --git a/tests/TeamUp.TestsCommon/DataGenerators/UserGenerators.cs b/tests/TeamUp.EndToEndTests/DataGenerators/UserGenerators.cs similarity index 94% rename from tests/TeamUp.TestsCommon/DataGenerators/UserGenerators.cs rename to tests/TeamUp.EndToEndTests/DataGenerators/UserGenerators.cs index fd31169..222f550 100644 --- a/tests/TeamUp.TestsCommon/DataGenerators/UserGenerators.cs +++ b/tests/TeamUp.EndToEndTests/DataGenerators/UserGenerators.cs @@ -1,4 +1,7 @@ -namespace TeamUp.TestsCommon.DataGenerators; +using TeamUp.Contracts.Teams; +using TeamUp.Contracts.Users; + +namespace TeamUp.EndToEndTests.DataGenerators; public sealed class UserGenerators : BaseGenerator { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/BaseEndpointTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/BaseEndpointTests.cs index ca4784b..531614d 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/BaseEndpointTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/BaseEndpointTests.cs @@ -11,7 +11,8 @@ namespace TeamUp.EndToEndTests.EndpointTests; [Collection(nameof(AppCollectionFixture))] public abstract class BaseEndpointTests : IAsyncLifetime { - protected static Faker F => FakerExtensions.F; + protected static Faker F => FExt.F; + protected static object EmptyObject { get; } = new { }; protected TeamApiWebApplicationFactory AppFactory { get; } protected HttpClient Client { get; } @@ -23,7 +24,7 @@ public BaseEndpointTests(TeamApiWebApplicationFactory appFactory) { AppFactory = appFactory; Client = appFactory.CreateClient(); - Client.BaseAddress = new Uri($"https://{Client.BaseAddress?.Host}:{TeamApiWebApplicationFactory.HTTPS_PORT}"); + Client.BaseAddress = new Uri($"https://{Client.BaseAddress?.Host}:8080"); Inbox = appFactory.Services.GetRequiredService(); BackgroundCallback = appFactory.Services.GetRequiredService(); diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Events/BaseEventTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Events/BaseEventTests.cs index 197a3cb..4fe8dd6 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Events/BaseEventTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Events/BaseEventTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Events; +using TeamUp.Contracts.Events; + +namespace TeamUp.EndToEndTests.EndpointTests.Events; public abstract class BaseEventTests : BaseEndpointTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Events/CreateEventTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Events/CreateEventTests.cs index c370eae..b123c5b 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Events/CreateEventTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Events/CreateEventTests.cs @@ -1,4 +1,7 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Events; +using TeamUp.Contracts.Events; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Events; public sealed class CreateEventTests : BaseEventTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventTests.cs index 6683624..bd31e21 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventTests.cs @@ -1,4 +1,7 @@ -using EventResponse = TeamUp.Contracts.Events.EventResponse; +using TeamUp.Contracts.Events; +using TeamUp.Contracts.Teams; + +using EventResponse = TeamUp.Contracts.Events.EventResponse; namespace TeamUp.EndToEndTests.EndpointTests.Events; diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventsTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventsTests.cs index f9398e0..9b5410a 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventsTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Events/GetEventsTests.cs @@ -1,4 +1,9 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Events; +using FluentAssertions.Extensions; + +using TeamUp.Contracts.Events; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Events; public sealed class GetEventsTests : BaseEventTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Events/UpsertEventReplyTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Events/UpsertEventReplyTests.cs index 842ae5e..b561eda 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Events/UpsertEventReplyTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Events/UpsertEventReplyTests.cs @@ -1,5 +1,8 @@ using Microsoft.EntityFrameworkCore; +using TeamUp.Contracts.Events; +using TeamUp.Contracts.Teams; + using EventResponse = TeamUp.Domain.Aggregates.Events.EventResponse; namespace TeamUp.EndToEndTests.EndpointTests.Events; diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/HttpsRedirectionTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/HttpsRedirectionTests.cs index 53cf82b..05a5046 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/HttpsRedirectionTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/HttpsRedirectionTests.cs @@ -11,6 +11,8 @@ namespace TeamUp.EndToEndTests.EndpointTests; [Collection(nameof(AppCollectionFixture))] public sealed class HttpsRedirectionTests : IAsyncLifetime { + private static Faker F => FExt.F; + private readonly TeamApiWebApplicationFactory _appFactory; private readonly HttpClient _client; @@ -42,7 +44,7 @@ private void Authenticate(User user) public async Task HttpRequest_ToHealthCheckEndpoint_Should_RedirectToHttps() { //arrange - var expectedLocation = $"https://{_client.BaseAddress?.Host}:{TeamApiWebApplicationFactory.HTTPS_PORT}/_health"; + var expectedLocation = $"https://{_client.BaseAddress?.Host}:8080/_health"; //act var response = await _client.GetAsync("/_health"); diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/AcceptInvitationTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/AcceptInvitationTests.cs index 33c0f7f..06df1d4 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/AcceptInvitationTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/AcceptInvitationTests.cs @@ -1,5 +1,8 @@ using Microsoft.EntityFrameworkCore; +using TeamUp.Contracts.Invitations; +using TeamUp.Contracts.Teams; + namespace TeamUp.EndToEndTests.EndpointTests.Invitations; public sealed class AcceptInvitationTests : BaseInvitationTests diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetMyInvitationsTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetMyInvitationsTests.cs index d2c3a57..c7d0305 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetMyInvitationsTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetMyInvitationsTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Invitations; +using TeamUp.Contracts.Invitations; + +namespace TeamUp.EndToEndTests.EndpointTests.Invitations; public sealed class GetMyInvitationsTests : BaseInvitationTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetTeamInvitationsTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetTeamInvitationsTests.cs index d572b88..6b0e037 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetTeamInvitationsTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/GetTeamInvitationsTests.cs @@ -1,4 +1,7 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Invitations; +using TeamUp.Contracts.Invitations; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Invitations; public sealed class GetTeamInvitationsTests : BaseInvitationTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/InviteUserTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/InviteUserTests.cs index da7f4a5..e65aa6b 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/InviteUserTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/InviteUserTests.cs @@ -1,4 +1,8 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Invitations; +using TeamUp.Contracts.Invitations; +using TeamUp.Contracts.Teams; +using TeamUp.Contracts.Users; + +namespace TeamUp.EndToEndTests.EndpointTests.Invitations; public sealed class InviteUserTests : BaseInvitationTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/RemoveInvitationTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/RemoveInvitationTests.cs index f2a904b..984024e 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/RemoveInvitationTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Invitations/RemoveInvitationTests.cs @@ -1,4 +1,7 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Invitations; +using TeamUp.Contracts.Invitations; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Invitations; public sealed class RemoveInvitationTests : BaseInvitationTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeNicknameTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeNicknameTests.cs index 15898d4..088fbbd 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeNicknameTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeNicknameTests.cs @@ -1,5 +1,7 @@ using Microsoft.EntityFrameworkCore; +using TeamUp.Contracts.Teams; + namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class ChangeNicknameTests : BaseTeamTests diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeOwnershipTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeOwnershipTests.cs index 028cbcf..691bf41 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeOwnershipTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/ChangeOwnershipTests.cs @@ -1,5 +1,7 @@ using Microsoft.EntityFrameworkCore; +using TeamUp.Contracts.Teams; + namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class ChangeOwnershipTests : BaseTeamTests diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateEventTypeTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateEventTypeTests.cs index e4903c5..5e35892 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateEventTypeTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateEventTypeTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Teams; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class CreateEventTypeTests : BaseTeamTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateTeamTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateTeamTests.cs index e58ef63..955322b 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateTeamTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/CreateTeamTests.cs @@ -1,5 +1,7 @@ using Microsoft.EntityFrameworkCore; +using TeamUp.Contracts.Teams; + namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class CreateTeamTests : BaseTeamTests diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/DeleteTeamTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/DeleteTeamTests.cs index e670322..efa3c57 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/DeleteTeamTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/DeleteTeamTests.cs @@ -1,6 +1,6 @@ using Microsoft.EntityFrameworkCore; -using EventResponse = TeamUp.Domain.Aggregates.Events.EventResponse; +using TeamUp.Contracts.Teams; namespace TeamUp.EndToEndTests.EndpointTests.Teams; diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/GetTeamTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/GetTeamTests.cs index f35da17..1a1374d 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/GetTeamTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/GetTeamTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Teams; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class GetTeamTests : BaseTeamTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/RemoveTeamMemberTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/RemoveTeamMemberTests.cs index e6f03a7..489a108 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/RemoveTeamMemberTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/RemoveTeamMemberTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Teams; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class RemoveTeamMemberTests : BaseTeamTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamMemberRoleTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamMemberRoleTests.cs index 30c4ae8..dd906dd 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamMemberRoleTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamMemberRoleTests.cs @@ -1,5 +1,7 @@ using Microsoft.EntityFrameworkCore; +using TeamUp.Contracts.Teams; + namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class UpdateTeamMemberRoleTests : BaseTeamTests diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamNameTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamNameTests.cs index bc3115a..ae6f0d3 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamNameTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/Teams/UpdateTeamNameTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.Teams; +using TeamUp.Contracts.Teams; + +namespace TeamUp.EndToEndTests.EndpointTests.Teams; public sealed class UpdateTeamNameTests : BaseTeamTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/ActivateAccountTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/ActivateAccountTests.cs index 49d3a85..c905793 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/ActivateAccountTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/ActivateAccountTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; +using TeamUp.Contracts.Users; + +namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; public sealed class ActivateAccountTests : BaseUserAccessTests { @@ -20,7 +22,7 @@ await UseDbContextAsync(dbContext => }); //act - var response = await Client.PostAsync(GetUrl(user.Id), null); + var response = await Client.PostAsJsonAsync(GetUrl(user.Id), EmptyObject); //assert response.Should().Be200Ok(); diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/GetMyAccountDetailsTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/GetMyAccountDetailsTests.cs index 93edfee..47a29c1 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/GetMyAccountDetailsTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/GetMyAccountDetailsTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; +using TeamUp.Contracts.Users; + +namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; public sealed class GetMyAccountDetailsTests : BaseUserAccessTests { diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/LoginTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/LoginTests.cs index f88661e..8e8ec53 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/LoginTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/LoginTests.cs @@ -2,6 +2,7 @@ using System.Security.Claims; using TeamUp.Application.Users; +using TeamUp.Contracts.Users; namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; diff --git a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/RegisterUserTests.cs b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/RegisterUserTests.cs index 18a4d6a..b4c319a 100644 --- a/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/RegisterUserTests.cs +++ b/tests/TeamUp.EndToEndTests/EndpointTests/UserAccess/RegisterUserTests.cs @@ -1,4 +1,6 @@ -namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; +using TeamUp.Contracts.Users; + +namespace TeamUp.EndToEndTests.EndpointTests.UserAccess; public sealed class RegisterUserTests : BaseUserAccessTests { diff --git a/tests/TeamUp.TestsCommon/Extensions/TheoryDataExtensions.cs b/tests/TeamUp.EndToEndTests/Extensions/TheoryDataExtensions.cs similarity index 88% rename from tests/TeamUp.TestsCommon/Extensions/TheoryDataExtensions.cs rename to tests/TeamUp.EndToEndTests/Extensions/TheoryDataExtensions.cs index 74588ae..e98b9d3 100644 --- a/tests/TeamUp.TestsCommon/Extensions/TheoryDataExtensions.cs +++ b/tests/TeamUp.EndToEndTests/Extensions/TheoryDataExtensions.cs @@ -1,6 +1,6 @@ using System.Linq.Expressions; -namespace TeamUp.TestsCommon.Extensions; +namespace TeamUp.EndToEndTests.Extensions; public static class TheoryDataExtensions { diff --git a/tests/TeamUp.TestsCommon/Extensions/TimeExtensions.cs b/tests/TeamUp.EndToEndTests/Extensions/TimeExtensions.cs similarity index 90% rename from tests/TeamUp.TestsCommon/Extensions/TimeExtensions.cs rename to tests/TeamUp.EndToEndTests/Extensions/TimeExtensions.cs index 7774b83..0d86a06 100644 --- a/tests/TeamUp.TestsCommon/Extensions/TimeExtensions.cs +++ b/tests/TeamUp.EndToEndTests/Extensions/TimeExtensions.cs @@ -1,4 +1,4 @@ -namespace TeamUp.TestsCommon.Extensions; +namespace TeamUp.EndToEndTests.Extensions; public static class TimeExtensions { diff --git a/tests/TeamUp.EndToEndTests/GlobalUsings.cs b/tests/TeamUp.EndToEndTests/GlobalUsings.cs index 961e823..ac1775c 100644 --- a/tests/TeamUp.EndToEndTests/GlobalUsings.cs +++ b/tests/TeamUp.EndToEndTests/GlobalUsings.cs @@ -3,22 +3,19 @@ global using Bogus; global using FluentAssertions; -global using FluentAssertions.Extensions; global using Microsoft.AspNetCore.Mvc; global using Microsoft.Extensions.DependencyInjection; -global using TeamUp.Contracts.Events; -global using TeamUp.Contracts.Invitations; -global using TeamUp.Contracts.Teams; -global using TeamUp.Contracts.Users; global using TeamUp.Domain.Aggregates.Events; global using TeamUp.Domain.Aggregates.Invitations; global using TeamUp.Domain.Aggregates.Teams; global using TeamUp.Domain.Aggregates.Users; +global using TeamUp.EndToEndTests.DataGenerators; global using TeamUp.EndToEndTests.Extensions; global using TeamUp.Infrastructure.Persistence; -global using TeamUp.TestsCommon.DataGenerators; -global using TeamUp.TestsCommon.Extensions; +global using TeamUp.TestsCommon; global using Xunit; + +global using FExt = TeamUp.TestsCommon.FakerExtensions; diff --git a/tests/TeamUp.EndToEndTests/Mocks/BackgroundCallback.cs b/tests/TeamUp.EndToEndTests/Mocks/BackgroundCallback.cs index cc4180b..1f95027 100644 --- a/tests/TeamUp.EndToEndTests/Mocks/BackgroundCallback.cs +++ b/tests/TeamUp.EndToEndTests/Mocks/BackgroundCallback.cs @@ -1,4 +1,5 @@ -namespace TeamUp.EndToEndTests.Mocks; + +namespace TeamUp.EndToEndTests.Mocks; internal abstract class BackgroundCallback { diff --git a/tests/TeamUp.EndToEndTests/TeamApiWebApplicationFactory.cs b/tests/TeamUp.EndToEndTests/TeamApiWebApplicationFactory.cs index bf5be5e..a28cd5c 100644 --- a/tests/TeamUp.EndToEndTests/TeamApiWebApplicationFactory.cs +++ b/tests/TeamUp.EndToEndTests/TeamApiWebApplicationFactory.cs @@ -21,8 +21,6 @@ public sealed class AppCollectionFixture : ICollectionFixture, IAsyncLifetime { - public const string HTTPS_PORT = "8181"; - private readonly PostgreSqlContainer _dbContainer = new PostgreSqlBuilder() .WithDatabase("POSTGRES") .WithUsername("POSTGRES") @@ -78,7 +76,7 @@ protected override void ConfigureWebHost(IWebHostBuilder builder) }); builder.UseEnvironment(Environments.Production); - builder.UseSetting("https_port", HTTPS_PORT); + builder.UseSetting("https_port", "8080"); } public new Task DisposeAsync() => _dbContainer.StopAsync(); diff --git a/tests/TeamUp.PerformanceTests/BasePerformanceTests.cs b/tests/TeamUp.PerformanceTests/BasePerformanceTests.cs deleted file mode 100644 index f0992f6..0000000 --- a/tests/TeamUp.PerformanceTests/BasePerformanceTests.cs +++ /dev/null @@ -1,89 +0,0 @@ -using System.Diagnostics; -using System.Net.Http.Headers; - -using Npgsql; - -using TeamUp.Application.Users; -using TeamUp.Infrastructure.Persistence; - -using Xunit.Abstractions; - -namespace TeamUp.EndToEndTests.EndpointTests; - -[Collection(nameof(AppCollectionFixture))] -public abstract class BasePerformanceTests : IAsyncLifetime -{ - protected static Faker F => FakerExtensions.F; - - protected TeamApiWebApplicationFactory AppFactory { get; } - protected ITestOutputHelper Output { get; } - protected HttpClient Client { get; } - - public BasePerformanceTests(TeamApiWebApplicationFactory appFactory, ITestOutputHelper output) - { - AppFactory = appFactory; - Output = output; - - Client = appFactory.CreateClient(); - Client.BaseAddress = new Uri($"https://{Client.BaseAddress?.Host}:{TeamApiWebApplicationFactory.HTTPS_PORT}"); - } - - public async Task InitializeAsync() - { - await using var connection = new NpgsqlConnection(AppFactory.ConnectionString); - await connection.OpenAsync(); - await AppFactory.Respawner.ResetAsync(connection); - } - - public void Authenticate(User user) - { - var tokenService = AppFactory.Services.GetRequiredService(); - var jwt = tokenService.GenerateToken(user); - - Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", jwt); - } - - protected async Task UseDbContextAsync(Func apply) - { - await using var scope = AppFactory.Services.CreateAsyncScope(); - - await using var dbContext = scope.ServiceProvider.GetRequiredService(); - await apply(dbContext); - - await scope.DisposeAsync(); - } - - protected async ValueTask UseDbContextAsync(Func> apply) - { - await using var scope = AppFactory.Services.CreateAsyncScope(); - - await using var dbContext = scope.ServiceProvider.GetRequiredService(); - var result = await apply(dbContext); - - await scope.DisposeAsync(); - return result; - } - - protected async Task UseDbContextAsync(Func> apply) - { - await using var scope = AppFactory.Services.CreateAsyncScope(); - - await using var dbContext = scope.ServiceProvider.GetRequiredService(); - var result = await apply(dbContext); - - await scope.DisposeAsync(); - return result; - } - - public async Task RunTestAsync(HttpRequestMessage message) - { - var timestamp = Stopwatch.GetTimestamp(); - var response = await Client.SendAsync(message); - var elapsed = Stopwatch.GetElapsedTime(timestamp); - - response.Should().Be200Ok(); - return elapsed; - } - - public Task DisposeAsync() => Task.CompletedTask; -} diff --git a/tests/TeamUp.PerformanceTests/GlobalUsings.cs b/tests/TeamUp.PerformanceTests/GlobalUsings.cs deleted file mode 100644 index 3fcce51..0000000 --- a/tests/TeamUp.PerformanceTests/GlobalUsings.cs +++ /dev/null @@ -1,22 +0,0 @@ -global using System.Net.Http.Json; - -global using Bogus; - -global using FluentAssertions; -global using FluentAssertions.Extensions; - -global using Microsoft.AspNetCore.Mvc; -global using Microsoft.Extensions.DependencyInjection; - -global using TeamUp.Contracts.Events; -global using TeamUp.Contracts.Invitations; -global using TeamUp.Contracts.Teams; -global using TeamUp.Contracts.Users; -global using TeamUp.Domain.Aggregates.Events; -global using TeamUp.Domain.Aggregates.Invitations; -global using TeamUp.Domain.Aggregates.Teams; -global using TeamUp.Domain.Aggregates.Users; -global using TeamUp.TestsCommon.DataGenerators; -global using TeamUp.TestsCommon.Extensions; - -global using Xunit; diff --git a/tests/TeamUp.PerformanceTests/SmokeTests/EventsSmokeTests.cs b/tests/TeamUp.PerformanceTests/SmokeTests/EventsSmokeTests.cs deleted file mode 100644 index 25d0ffd..0000000 --- a/tests/TeamUp.PerformanceTests/SmokeTests/EventsSmokeTests.cs +++ /dev/null @@ -1,125 +0,0 @@ -using TeamUp.EndToEndTests; -using TeamUp.EndToEndTests.EndpointTests; - -using Xunit.Abstractions; - -namespace TeamUp.PerformanceTests.SmokeTests; - -public sealed class EventsSmokeTests : BasePerformanceTests -{ - public EventsSmokeTests(TeamApiWebApplicationFactory appFactory, ITestOutputHelper output) : base(appFactory, output) { } - - [Fact] - public async Task GetEvents_SmokeTest() - { - //arrange - var users = UserGenerators.ActivatedUser.Generate(2000); - var teams = TeamGenerators.Team - .WithRandomMembers(30, users) - .WithEventTypes(5) - .Generate(100); - var events = teams - .Select(team => EventGenerators.Event - .ForTeam(team.Id) - .WithEventType(team.EventTypes[0].Id) - .WithStatus(EventStatus.Open) - .WithRandomEventResponses(team.Members) - .Generate(50)) - .SelectMany(teamEvents => teamEvents) - .ToList(); - - await UseDbContextAsync(dbContext => - { - dbContext.Users.AddRange(users); - dbContext.Teams.AddRange(teams); - dbContext.Events.AddRange(events); - return dbContext.SaveChangesAsync(); - }); - - var iterations = 8; - var runs = new TimeSpan[iterations]; - - //act - for (int i = 0; i < iterations; i++) - { - var targetTeam = F.PickRandom(teams); - var initiatorMember = F.PickRandomFromReadOnlyList(targetTeam.Members); - var initiatorUser = users.First(user => user.Id == initiatorMember.UserId); - - Authenticate(initiatorUser); - - var request = new HttpRequestMessage(HttpMethod.Get, $"/api/v1/teams/{targetTeam.Id.Value}/events"); - - //act - runs[i] = await RunTestAsync(request); - - Output.WriteLine($"{i}. iteration: {runs[i]} ({runs[i].TotalMilliseconds} ms)"); - } - - //assert - var firstRun = runs[0]; - var avg = TimeSpan.FromTicks((long)runs[1..].Average(x => x.Ticks)); - - Output.WriteLine($"average time without first run: {avg} ({avg.TotalMilliseconds} ms)"); - - avg.Should().BeLessThan(TimeSpan.FromMilliseconds(15)); - firstRun.Should().BeLessThan(TimeSpan.FromMilliseconds(200)); - } - - [Fact] - public async Task GetEvent_SmokeTest() - { - var users = UserGenerators.ActivatedUser.Generate(2000); - var teams = TeamGenerators.Team - .WithRandomMembers(30, users) - .WithEventTypes(5) - .Generate(100); - var events = teams - .Select(team => EventGenerators.Event - .ForTeam(team.Id) - .WithEventType(team.EventTypes[0].Id) - .WithStatus(EventStatus.Open) - .WithRandomEventResponses(team.Members) - .Generate(50)) - .SelectMany(teamEvents => teamEvents) - .ToList(); - - await UseDbContextAsync(dbContext => - { - dbContext.Users.AddRange(users); - dbContext.Teams.AddRange(teams); - dbContext.Events.AddRange(events); - return dbContext.SaveChangesAsync(); - }); - - var iterations = 8; - var runs = new TimeSpan[iterations]; - - //act - for (int i = 0; i < iterations; i++) - { - var targetTeam = F.PickRandom(teams); - var initiatorMember = F.PickRandomFromReadOnlyList(targetTeam.Members); - var initiatorUser = users.First(user => user.Id == initiatorMember.UserId); - var targetEvent = F.PickRandom(events.Where(e => e.TeamId == targetTeam.Id)); - - Authenticate(initiatorUser); - - var request = new HttpRequestMessage(HttpMethod.Get, $"/api/v1/teams/{targetTeam.Id.Value}/events/{targetEvent.Id.Value}"); - - //act - runs[i] = await RunTestAsync(request); - - Output.WriteLine($"{i}. iteration: {runs[i]} ({runs[i].TotalMilliseconds} ms)"); - } - - //assert - var firstRun = runs[0]; - var avg = TimeSpan.FromTicks((long)runs[1..].Average(x => x.Ticks)); - - Output.WriteLine($"average time without first run: {avg} ({avg.TotalMilliseconds} ms)"); - - avg.Should().BeLessThan(TimeSpan.FromMilliseconds(15)); - firstRun.Should().BeLessThan(TimeSpan.FromMilliseconds(800)); - } -} diff --git a/tests/TeamUp.PerformanceTests/TeamApiWebApplicationFactory.cs b/tests/TeamUp.PerformanceTests/TeamApiWebApplicationFactory.cs deleted file mode 100644 index c6e7edc..0000000 --- a/tests/TeamUp.PerformanceTests/TeamApiWebApplicationFactory.cs +++ /dev/null @@ -1,72 +0,0 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Hosting; - -using Npgsql; - -using Respawn; - -using TeamUp.Infrastructure.Persistence; - -using Testcontainers.PostgreSql; - -namespace TeamUp.EndToEndTests; - -[CollectionDefinition(nameof(AppCollectionFixture))] -public sealed class AppCollectionFixture : ICollectionFixture; - -public sealed class TeamApiWebApplicationFactory : WebApplicationFactory, IAsyncLifetime -{ - public const string HTTPS_PORT = "8181"; - - private readonly PostgreSqlContainer _dbContainer = new PostgreSqlBuilder() - .WithDatabase("POSTGRES") - .WithUsername("POSTGRES") - .WithPassword("DEVPASS") - .Build(); - - public string ConnectionString => _dbContainer.GetConnectionString(); - public Respawner Respawner { get; set; } = null!; - - public async Task InitializeAsync() - { - await _dbContainer.StartAsync(); - - Randomizer.Seed = new Random(420_069); - Faker.DefaultStrictMode = true; - - await using var scope = Server.Services.CreateAsyncScope(); - await using var dbContext = scope.ServiceProvider.GetRequiredService(); - await dbContext.Database.MigrateAsync(); - - await using var connection = new NpgsqlConnection(ConnectionString); - await connection.OpenAsync(); - - Respawner = await Respawner.CreateAsync(connection, new() - { - DbAdapter = DbAdapter.Postgres - }); - } - - protected override void ConfigureWebHost(IWebHostBuilder builder) - { - builder.ConfigureServices(services => - { - //db context - services.RemoveAll(); - services.RemoveAll>(); - services.RemoveAll(); - services.AddDbContext(options => - { - options.UseNpgsql(ConnectionString); - }); - }); - - builder.UseEnvironment(Environments.Production); - builder.UseSetting("https_port", HTTPS_PORT); - } - - public new Task DisposeAsync() => _dbContainer.StopAsync(); -} diff --git a/tests/TeamUp.PerformanceTests/TeamUp.PerformanceTests.csproj b/tests/TeamUp.PerformanceTests/TeamUp.PerformanceTests.csproj deleted file mode 100644 index a714c9e..0000000 --- a/tests/TeamUp.PerformanceTests/TeamUp.PerformanceTests.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - - false - true - - - - - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - - - - - - - diff --git a/tests/TeamUp.TestsCommon/Extensions/AssertionExtensions.cs b/tests/TeamUp.TestsCommon/AssertionExtensions.cs similarity index 94% rename from tests/TeamUp.TestsCommon/Extensions/AssertionExtensions.cs rename to tests/TeamUp.TestsCommon/AssertionExtensions.cs index 2062a37..45d25d1 100644 --- a/tests/TeamUp.TestsCommon/Extensions/AssertionExtensions.cs +++ b/tests/TeamUp.TestsCommon/AssertionExtensions.cs @@ -1,10 +1,11 @@ using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using FluentAssertions; using FluentAssertions.Execution; using FluentAssertions.Primitives; -namespace TeamUp.TestsCommon.Extensions; +namespace TeamUp.TestsCommon; public static class AssertionExtensions { diff --git a/tests/TeamUp.TestsCommon/DataGenerators/BaseGenerator.cs b/tests/TeamUp.TestsCommon/DataGenerators/BaseGenerator.cs deleted file mode 100644 index 529f362..0000000 --- a/tests/TeamUp.TestsCommon/DataGenerators/BaseGenerator.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace TeamUp.TestsCommon.DataGenerators; - -public abstract class BaseGenerator -{ - protected static Faker F => FakerExtensions.F; -} diff --git a/tests/TeamUp.TestsCommon/Extensions/FakerExtensions.cs b/tests/TeamUp.TestsCommon/FakerExtensions.cs similarity index 86% rename from tests/TeamUp.TestsCommon/Extensions/FakerExtensions.cs rename to tests/TeamUp.TestsCommon/FakerExtensions.cs index 2064406..1a51051 100644 --- a/tests/TeamUp.TestsCommon/Extensions/FakerExtensions.cs +++ b/tests/TeamUp.TestsCommon/FakerExtensions.cs @@ -1,18 +1,14 @@ using System.Linq.Expressions; using System.Reflection; -namespace TeamUp.TestsCommon.Extensions; +using Bogus; + +namespace TeamUp.TestsCommon; public static class FakerExtensions { public static readonly Faker F = new(); - public static T PickRandomFromReadOnlyList(this Faker faker, IReadOnlyList list) where T : class - { - var index = faker.Random.Int(0, list.Count - 1); - return list[index]; - } - public static Faker UsePrivateConstructor(this Faker faker) where T : class => faker.CustomInstantiator(f => (Activator.CreateInstance(typeof(T), nonPublic: true) as T)!); diff --git a/tests/TeamUp.TestsCommon/GlobalUsings.cs b/tests/TeamUp.TestsCommon/GlobalUsings.cs deleted file mode 100644 index 9728a89..0000000 --- a/tests/TeamUp.TestsCommon/GlobalUsings.cs +++ /dev/null @@ -1,16 +0,0 @@ -global using Bogus; - -global using FluentAssertions; - -global using TeamUp.Contracts.Events; -global using TeamUp.Contracts.Invitations; -global using TeamUp.Contracts.Teams; -global using TeamUp.Contracts.Users; -global using TeamUp.Domain.Aggregates.Events; -global using TeamUp.Domain.Aggregates.Invitations; -global using TeamUp.Domain.Aggregates.Teams; -global using TeamUp.Domain.Aggregates.Users; -global using TeamUp.TestsCommon.DataGenerators; -global using TeamUp.TestsCommon.Extensions; - -global using Xunit; diff --git a/tests/TeamUp.TestsCommon/Extensions/RandomizerExtensions.cs b/tests/TeamUp.TestsCommon/RandomizerExtensions.cs similarity index 80% rename from tests/TeamUp.TestsCommon/Extensions/RandomizerExtensions.cs rename to tests/TeamUp.TestsCommon/RandomizerExtensions.cs index 898bbf1..122202f 100644 --- a/tests/TeamUp.TestsCommon/Extensions/RandomizerExtensions.cs +++ b/tests/TeamUp.TestsCommon/RandomizerExtensions.cs @@ -1,4 +1,6 @@ -namespace TeamUp.TestsCommon.Extensions; +using Bogus; + +namespace TeamUp.TestsCommon; public static class RandomizerExtensions { diff --git a/tests/TeamUp.TestsCommon/TeamUp.TestsCommon.csproj b/tests/TeamUp.TestsCommon/TeamUp.TestsCommon.csproj index 6fe8662..8e4cf39 100644 --- a/tests/TeamUp.TestsCommon/TeamUp.TestsCommon.csproj +++ b/tests/TeamUp.TestsCommon/TeamUp.TestsCommon.csproj @@ -3,12 +3,6 @@ - - - - - -