Refactor message service and move tests to Application.Tests

Renamed IMessageService to IMessageCommandService and updated all usages accordingly. Moved and renamed test files from Govor.API.Tests to the new Govor.Application.Tests project, updating namespaces to match. Refactored message-related services and controllers to use the new naming and structure. Added Govor.Application.Tests project to the solution.
This commit is contained in:
Artemy
2025-07-10 18:05:10 +07:00
parent a43a26b307
commit 65a43c09d3
33 changed files with 157 additions and 45 deletions
@@ -2,7 +2,7 @@ using Govor.API.Services.AdminsStuff.Interfaces;
using Govor.Core.Models;
using Govor.Core.Repositories.Invaites;
namespace Govor.Application.Interfaces.AdminsStuff;
namespace Govor.Application.Infrastructure.AdminsStuff;
public class InvitationGenerator(IInvitesRepository repository) : IInvitationGenerator
{
@@ -4,7 +4,7 @@ using Govor.Core.Models;
namespace Govor.Application.Interfaces.Messages;
// Combining IChatService and IGroupService functionalities relevant to messages
public interface IMessageService
public interface IMessageCommandService
{
Task<SendMessageResult> SendMessageAsync(SendMessage messageParameters);
Task<EditMessageResult> EditMessageAsync(EditMessage messageParameters);
@@ -8,7 +8,7 @@ using Govor.Application.Interfaces.Authentication;
using Govor.Core.Infrastructure.Validators;
using Govor.Core.Repositories.Admins;
namespace Govor.Application.Services;
namespace Govor.Application.Services.Authentication;
public class AuthService : IAccountService
{
@@ -1,4 +1,4 @@
namespace Govor.Application.Services;
namespace Govor.Application.Services.Authentication;
public class JwtOption
{
public string SecretKeу {get; set;}
@@ -6,7 +6,7 @@ using Govor.Core.Models;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
namespace Govor.Application.Services;
namespace Govor.Application.Services.Authentication;
public class JwtService : IJwtService
{
@@ -1,6 +1,6 @@
using Govor.Core.Infrastructure.Extensions;
namespace Govor.Application.Services;
namespace Govor.Application.Services.Authentication;
public class PasswordHasher : IPasswordHasher
{
@@ -1,7 +1,7 @@
using Govor.Application.Interfaces;
using Govor.Application.Interfaces.Medias;
namespace Govor.Application.Services;
namespace Govor.Application.Services.Messages;
public class MediaService : IMediaService
{
@@ -8,24 +8,24 @@ using Govor.Core.Repositories.PrivateChats;
using Govor.Core.Repositories.Users;
using Microsoft.Extensions.Logging;
namespace Govor.Application.Services;
namespace Govor.Application.Services.Messages;
public class MessageService : IMessageService
public class MessageCommandService : IMessageCommandService
{
private readonly IMessagesRepository _messagesRepository;
private readonly IUsersRepository _usersRepository; // For validating user recipients
private readonly IGroupsRepository _groupsRepository; // For validating group recipients and fetching members
private readonly IPrivateChatsRepository _privateChats;
private readonly IVerifyFriendship _verifyFriendship; // For private messages
private readonly ILogger<MessageService> _logger;
private readonly ILogger<MessageCommandService> _logger;
public MessageService(
public MessageCommandService(
IMessagesRepository messagesRepository,
IUsersRepository usersRepository,
IGroupsRepository groupsRepository,
IVerifyFriendship verifyFriendship,
IPrivateChatsRepository privateChats,
ILogger<MessageService> logger)
ILogger<MessageCommandService> logger)
{
_messagesRepository = messagesRepository;
_usersRepository = usersRepository;
@@ -4,7 +4,7 @@ using Govor.Core.Repositories.Groups;
using Govor.Core.Repositories.Messages;
using Govor.Data.Repositories.Exceptions;
namespace Govor.Application.Services;
namespace Govor.Application.Services.Messages;
public class MessagesLoader : IMessagesLoader
{