From c6f21918df2a5add919f0bf782a6c8102a991707 Mon Sep 17 00:00:00 2001 From: "D. Ror" Date: Wed, 5 Jun 2024 11:22:49 -0400 Subject: [PATCH] [Backend.Tests] Add `sealed internal` to Mock classes (#3049) --- Backend.Tests/Controllers/LiftControllerTests.cs | 2 +- Backend.Tests/Mocks/BannerRepositoryMock.cs | 2 +- Backend.Tests/Mocks/EmailServiceMock.cs | 2 +- Backend.Tests/Mocks/HubContextMock.cs | 6 +++--- Backend.Tests/Mocks/MergeBlacklistRepositoryMock.cs | 2 +- Backend.Tests/Mocks/MergeGraylistRepositoryMock.cs | 2 +- Backend.Tests/Mocks/PasswordResetContextMock.cs | 2 +- Backend.Tests/Mocks/PasswordResetServiceMock.cs | 2 +- Backend.Tests/Mocks/PermissionServiceMock.cs | 4 ++-- Backend.Tests/Mocks/ProjectRepositoryMock.cs | 2 +- Backend.Tests/Mocks/SemanticDomainRepositoryMock.cs | 2 +- Backend.Tests/Mocks/SpeakerRepositoryMock.cs | 2 +- Backend.Tests/Mocks/StatisticsServiceMock.cs | 2 +- Backend.Tests/Mocks/UserEditRepositoryMock.cs | 2 +- Backend.Tests/Mocks/UserRepositoryMock.cs | 4 ++-- Backend.Tests/Mocks/UserRoleRepositoryMock.cs | 2 +- Backend.Tests/Mocks/WordRepositoryMock.cs | 2 +- 17 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Backend.Tests/Controllers/LiftControllerTests.cs b/Backend.Tests/Controllers/LiftControllerTests.cs index cd093c72a1..f6f4c596c7 100644 --- a/Backend.Tests/Controllers/LiftControllerTests.cs +++ b/Backend.Tests/Controllers/LiftControllerTests.cs @@ -684,7 +684,7 @@ public void TestRoundtrip(RoundTripObj roundTripObj) } } - private class MockLogger : ILogger + private sealed class MockLogger : ILogger { public IDisposable BeginScope(TState state) { diff --git a/Backend.Tests/Mocks/BannerRepositoryMock.cs b/Backend.Tests/Mocks/BannerRepositoryMock.cs index 296cba5bde..4044079fb0 100644 --- a/Backend.Tests/Mocks/BannerRepositoryMock.cs +++ b/Backend.Tests/Mocks/BannerRepositoryMock.cs @@ -6,7 +6,7 @@ namespace Backend.Tests.Mocks { - public class BannerRepositoryMock : IBannerRepository + sealed internal class BannerRepositoryMock : IBannerRepository { private Dictionary _banners; diff --git a/Backend.Tests/Mocks/EmailServiceMock.cs b/Backend.Tests/Mocks/EmailServiceMock.cs index 9f2439186b..8157ca5a1d 100644 --- a/Backend.Tests/Mocks/EmailServiceMock.cs +++ b/Backend.Tests/Mocks/EmailServiceMock.cs @@ -4,7 +4,7 @@ namespace Backend.Tests.Mocks { - internal class EmailServiceMock : IEmailService + sealed internal class EmailServiceMock : IEmailService { public Task SendEmail(MimeMessage msg) { diff --git a/Backend.Tests/Mocks/HubContextMock.cs b/Backend.Tests/Mocks/HubContextMock.cs index 3f01c8c296..b7c119cee2 100644 --- a/Backend.Tests/Mocks/HubContextMock.cs +++ b/Backend.Tests/Mocks/HubContextMock.cs @@ -9,14 +9,14 @@ namespace Backend.Tests.Mocks /// /// A *very* sparse, mostly unimplemented Mock of SignalR HubContext. /// - public class HubContextMock : IHubContext + sealed internal class HubContextMock : IHubContext { public IHubClients Clients => new HubClientsMock(); public IGroupManager Groups => throw new System.NotImplementedException(); } - public class HubClientsMock : IHubClients + sealed internal class HubClientsMock : IHubClients { public IClientProxy AllExcept(IReadOnlyList excludedConnectionIds) { @@ -61,7 +61,7 @@ public IClientProxy Users(IReadOnlyList userIds) public IClientProxy All => new ClientProxyMock(); } - public class ClientProxyMock : IClientProxy + sealed internal class ClientProxyMock : IClientProxy { // Disable this warning as this mock simply needs to return an empty Task, not await anything. #pragma warning disable 1998 diff --git a/Backend.Tests/Mocks/MergeBlacklistRepositoryMock.cs b/Backend.Tests/Mocks/MergeBlacklistRepositoryMock.cs index 2f81c3e0fc..9b76f6ef8c 100644 --- a/Backend.Tests/Mocks/MergeBlacklistRepositoryMock.cs +++ b/Backend.Tests/Mocks/MergeBlacklistRepositoryMock.cs @@ -8,7 +8,7 @@ namespace Backend.Tests.Mocks { - public class MergeBlacklistRepositoryMock : IMergeBlacklistRepository + sealed internal class MergeBlacklistRepositoryMock : IMergeBlacklistRepository { private readonly List _mergeBlacklist; diff --git a/Backend.Tests/Mocks/MergeGraylistRepositoryMock.cs b/Backend.Tests/Mocks/MergeGraylistRepositoryMock.cs index edfaba57eb..db71616571 100644 --- a/Backend.Tests/Mocks/MergeGraylistRepositoryMock.cs +++ b/Backend.Tests/Mocks/MergeGraylistRepositoryMock.cs @@ -8,7 +8,7 @@ namespace Backend.Tests.Mocks { - public class MergeGraylistRepositoryMock : IMergeGraylistRepository + sealed internal class MergeGraylistRepositoryMock : IMergeGraylistRepository { private readonly List _mergeGraylist; diff --git a/Backend.Tests/Mocks/PasswordResetContextMock.cs b/Backend.Tests/Mocks/PasswordResetContextMock.cs index 99bdb549cb..47cf005761 100644 --- a/Backend.Tests/Mocks/PasswordResetContextMock.cs +++ b/Backend.Tests/Mocks/PasswordResetContextMock.cs @@ -6,7 +6,7 @@ namespace Backend.Tests.Mocks { - public class PasswordResetContextMock : IPasswordResetContext + sealed internal class PasswordResetContextMock : IPasswordResetContext { private List _resets; diff --git a/Backend.Tests/Mocks/PasswordResetServiceMock.cs b/Backend.Tests/Mocks/PasswordResetServiceMock.cs index 10f41e0c5c..ad1313e046 100644 --- a/Backend.Tests/Mocks/PasswordResetServiceMock.cs +++ b/Backend.Tests/Mocks/PasswordResetServiceMock.cs @@ -4,7 +4,7 @@ namespace Backend.Tests.Mocks { - internal class PasswordResetServiceMock : IPasswordResetService + sealed internal class PasswordResetServiceMock : IPasswordResetService { public Task CreatePasswordReset(string email) { diff --git a/Backend.Tests/Mocks/PermissionServiceMock.cs b/Backend.Tests/Mocks/PermissionServiceMock.cs index 5db55cdeea..9a82a3340e 100644 --- a/Backend.Tests/Mocks/PermissionServiceMock.cs +++ b/Backend.Tests/Mocks/PermissionServiceMock.cs @@ -7,7 +7,7 @@ namespace Backend.Tests.Mocks { - internal class PermissionServiceMock : IPermissionService + sealed internal class PermissionServiceMock : IPermissionService { private readonly IUserRepository _userRepo; private const string NoHttpContextAvailable = "NO_HTTP_CONTEXT_AVAILABLE"; @@ -157,7 +157,7 @@ public string GetUserId(HttpContext? request) } [Serializable] - public class UserAuthenticationException : Exception + internal class UserAuthenticationException : Exception { public UserAuthenticationException() { } diff --git a/Backend.Tests/Mocks/ProjectRepositoryMock.cs b/Backend.Tests/Mocks/ProjectRepositoryMock.cs index 0b3e77628b..be9465e994 100644 --- a/Backend.Tests/Mocks/ProjectRepositoryMock.cs +++ b/Backend.Tests/Mocks/ProjectRepositoryMock.cs @@ -9,7 +9,7 @@ namespace Backend.Tests.Mocks { - public class ProjectRepositoryMock : IProjectRepository + sealed internal class ProjectRepositoryMock : IProjectRepository { private readonly List _projects; diff --git a/Backend.Tests/Mocks/SemanticDomainRepositoryMock.cs b/Backend.Tests/Mocks/SemanticDomainRepositoryMock.cs index 42da227bae..562328bb67 100644 --- a/Backend.Tests/Mocks/SemanticDomainRepositoryMock.cs +++ b/Backend.Tests/Mocks/SemanticDomainRepositoryMock.cs @@ -5,7 +5,7 @@ namespace Backend.Tests.Mocks { - public class SemanticDomainRepositoryMock : ISemanticDomainRepository + sealed internal class SemanticDomainRepositoryMock : ISemanticDomainRepository { private object? _responseObj; diff --git a/Backend.Tests/Mocks/SpeakerRepositoryMock.cs b/Backend.Tests/Mocks/SpeakerRepositoryMock.cs index 907024447f..7483b004ed 100644 --- a/Backend.Tests/Mocks/SpeakerRepositoryMock.cs +++ b/Backend.Tests/Mocks/SpeakerRepositoryMock.cs @@ -8,7 +8,7 @@ namespace Backend.Tests.Mocks { - public class SpeakerRepositoryMock : ISpeakerRepository + sealed internal class SpeakerRepositoryMock : ISpeakerRepository { private readonly List _speakers; diff --git a/Backend.Tests/Mocks/StatisticsServiceMock.cs b/Backend.Tests/Mocks/StatisticsServiceMock.cs index 8a0a3062f2..dcf9864fe4 100644 --- a/Backend.Tests/Mocks/StatisticsServiceMock.cs +++ b/Backend.Tests/Mocks/StatisticsServiceMock.cs @@ -6,7 +6,7 @@ namespace Backend.Tests.Mocks { - internal class StatisticsServiceMock : IStatisticsService + sealed internal class StatisticsServiceMock : IStatisticsService { public Task> GetSemanticDomainCounts(string projectId, string lang) { diff --git a/Backend.Tests/Mocks/UserEditRepositoryMock.cs b/Backend.Tests/Mocks/UserEditRepositoryMock.cs index 871be006e6..ca32f91d17 100644 --- a/Backend.Tests/Mocks/UserEditRepositoryMock.cs +++ b/Backend.Tests/Mocks/UserEditRepositoryMock.cs @@ -7,7 +7,7 @@ namespace Backend.Tests.Mocks { - public class UserEditRepositoryMock : IUserEditRepository + sealed internal class UserEditRepositoryMock : IUserEditRepository { private readonly List _userEdits; diff --git a/Backend.Tests/Mocks/UserRepositoryMock.cs b/Backend.Tests/Mocks/UserRepositoryMock.cs index 681623a8ca..c386eb202f 100644 --- a/Backend.Tests/Mocks/UserRepositoryMock.cs +++ b/Backend.Tests/Mocks/UserRepositoryMock.cs @@ -9,7 +9,7 @@ namespace Backend.Tests.Mocks { - public class UserRepositoryMock : IUserRepository + sealed internal class UserRepositoryMock : IUserRepository { private readonly List _users; @@ -103,7 +103,7 @@ public Task ChangePassword(string userId, string password) } [Serializable] - public class UserCreationException : Exception + internal class UserCreationException : Exception { public UserCreationException() { } diff --git a/Backend.Tests/Mocks/UserRoleRepositoryMock.cs b/Backend.Tests/Mocks/UserRoleRepositoryMock.cs index 13edd049b5..bce50cb685 100644 --- a/Backend.Tests/Mocks/UserRoleRepositoryMock.cs +++ b/Backend.Tests/Mocks/UserRoleRepositoryMock.cs @@ -8,7 +8,7 @@ namespace Backend.Tests.Mocks { - public class UserRoleRepositoryMock : IUserRoleRepository + sealed internal class UserRoleRepositoryMock : IUserRoleRepository { private readonly List _userRoles; diff --git a/Backend.Tests/Mocks/WordRepositoryMock.cs b/Backend.Tests/Mocks/WordRepositoryMock.cs index 242de776b2..eb3efee4ac 100644 --- a/Backend.Tests/Mocks/WordRepositoryMock.cs +++ b/Backend.Tests/Mocks/WordRepositoryMock.cs @@ -7,7 +7,7 @@ namespace Backend.Tests.Mocks { - public class WordRepositoryMock : IWordRepository + sealed internal class WordRepositoryMock : IWordRepository { private readonly List _words; private readonly List _frontier;