mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
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:
@@ -27,5 +27,4 @@
|
|||||||
<ProjectReference Include="..\Govor.API\Govor.API.csproj" />
|
<ProjectReference Include="..\Govor.API\Govor.API.csproj" />
|
||||||
<ProjectReference Include="..\Govor.Data\Govor.Data.csproj" />
|
<ProjectReference Include="..\Govor.Data\Govor.Data.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Govor.API.Tests.IntegrationTests.Hubs;
|
|||||||
public class ChatsHubTests
|
public class ChatsHubTests
|
||||||
{
|
{
|
||||||
private Mock<ILogger<ChatsHub>> _loggerMock;
|
private Mock<ILogger<ChatsHub>> _loggerMock;
|
||||||
private Mock<IMessageService> _messageServiceMock;
|
private Mock<IMessageCommandService> _messageServiceMock;
|
||||||
private Mock<IUserGroupsService> _userGroupsServiceMock;
|
private Mock<IUserGroupsService> _userGroupsServiceMock;
|
||||||
private Fixture _fixture;
|
private Fixture _fixture;
|
||||||
private ChatsHub _chatsHub;
|
private ChatsHub _chatsHub;
|
||||||
@@ -23,7 +23,7 @@ public class ChatsHubTests
|
|||||||
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList().ForEach(b => _fixture.Behaviors.Remove(b));
|
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList().ForEach(b => _fixture.Behaviors.Remove(b));
|
||||||
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
|
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
|
||||||
|
|
||||||
_messageServiceMock = new Mock<IMessageService>();
|
_messageServiceMock = new Mock<IMessageCommandService>();
|
||||||
_userGroupsServiceMock = new Mock<IUserGroupsService>();
|
_userGroupsServiceMock = new Mock<IUserGroupsService>();
|
||||||
_loggerMock = new Mock<ILogger<ChatsHub>>();
|
_loggerMock = new Mock<ILogger<ChatsHub>>();
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ using Govor.Application.Services;
|
|||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Services;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class LocalStorageServiceTests
|
public class LocalStorageServiceTests
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
using Govor.Application.Interfaces.Friends;
|
||||||
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
@@ -8,5 +10,18 @@ namespace Govor.API.Controllers.Friends;
|
|||||||
[Route("api/friends")]
|
[Route("api/friends")]
|
||||||
public class FriendsRequestQueryController : Controller
|
public class FriendsRequestQueryController : Controller
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<FriendsController> _logger;
|
||||||
|
private readonly IFriendRequestQueryService _friendsService;
|
||||||
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
|
||||||
|
public FriendsRequestQueryController(ILogger<FriendsController> logger,
|
||||||
|
IFriendRequestQueryService friendsService,
|
||||||
|
ICurrentUserService currentUserService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_friendsService = friendsService;
|
||||||
|
_currentUserService = currentUserService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,59 @@
|
|||||||
|
using Govor.Application.Exceptions.FriendsService;
|
||||||
|
using Govor.Application.Interfaces.Friends;
|
||||||
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
|
using Govor.Contracts.DTOs;
|
||||||
|
using Govor.Core.Models;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace Govor.API.Controllers.Friends;
|
namespace Govor.API.Controllers.Friends;
|
||||||
|
|
||||||
public class FriendshipController
|
[Route("api/friends")]
|
||||||
|
public class FriendshipController : Controller
|
||||||
{
|
{
|
||||||
|
private readonly ILogger<FriendsController> _logger;
|
||||||
|
private readonly IFriendshipService _friendsService;
|
||||||
|
//private readonly IUserDtoBuilder _builder;
|
||||||
|
private readonly ICurrentUserService _currentUserService;
|
||||||
|
|
||||||
|
public FriendshipController(ILogger<FriendsController> logger,
|
||||||
|
IFriendshipService friendsService,
|
||||||
|
ICurrentUserService currentUserService)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_friendsService = friendsService;
|
||||||
|
_currentUserService = currentUserService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("search")] // api/friends/search?query=
|
||||||
|
public async Task<IActionResult> Search(string query)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
|
return BadRequest("Query cannot be empty");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var result = await _friendsService.SearchUsersAsync(query, _currentUserService.GetCurrentUserId());
|
||||||
|
return Ok(BuildUserDtos(result));
|
||||||
|
}
|
||||||
|
catch (SearchUsersException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, ex.Message);
|
||||||
|
return NotFound(new { error = ex.Message });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, ex.Message);
|
||||||
|
return StatusCode(500, new { error = "Internal error during user search." });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<UserDto> BuildUserDtos(IEnumerable<User> users) => users.Select(user => new UserDto
|
||||||
|
{
|
||||||
|
Id = user.Id,
|
||||||
|
Username = user.Username,
|
||||||
|
Description = user.Description,
|
||||||
|
WasOnline = user.WasOnline,
|
||||||
|
IconId = user.IconId
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Govor.API.Services.AdminsStuff.Interfaces;
|
using Govor.API.Services.AdminsStuff.Interfaces;
|
||||||
using Govor.API.Services.Authentication.Interfaces;
|
using Govor.API.Services.Authentication.Interfaces;
|
||||||
|
using Govor.Application.Infrastructure.AdminsStuff;
|
||||||
using Govor.Application.Infrastructure.Extensions;
|
using Govor.Application.Infrastructure.Extensions;
|
||||||
using Govor.Application.Infrastructure.Validators;
|
using Govor.Application.Infrastructure.Validators;
|
||||||
using Govor.Application.Interfaces;
|
using Govor.Application.Interfaces;
|
||||||
@@ -9,7 +10,9 @@ using Govor.Application.Interfaces.Friends;
|
|||||||
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
using Govor.Application.Interfaces.Infrastructure.Extensions;
|
||||||
using Govor.Application.Interfaces.Messages;
|
using Govor.Application.Interfaces.Messages;
|
||||||
using Govor.Application.Services;
|
using Govor.Application.Services;
|
||||||
|
using Govor.Application.Services.Authentication;
|
||||||
using Govor.Application.Services.Friends;
|
using Govor.Application.Services.Friends;
|
||||||
|
using Govor.Application.Services.Messages;
|
||||||
using Govor.Core.Infrastructure.Extensions;
|
using Govor.Core.Infrastructure.Extensions;
|
||||||
using Govor.Core.Infrastructure.Validators;
|
using Govor.Core.Infrastructure.Validators;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
@@ -57,7 +60,7 @@ public static class ConfigurationProgramExtensions
|
|||||||
services.AddMemoryCache();
|
services.AddMemoryCache();
|
||||||
services.AddScoped<IPingHandlerService, PingHandlerService>();
|
services.AddScoped<IPingHandlerService, PingHandlerService>();
|
||||||
|
|
||||||
services.AddScoped<IMessageService, MessageService>();
|
services.AddScoped<IMessageCommandService, MessageCommandService>();
|
||||||
services.AddScoped<IVerifyFriendship, VerifyFriendship>();
|
services.AddScoped<IVerifyFriendship, VerifyFriendship>();
|
||||||
services.AddScoped<IUserGroupsService, UserGroupsService>();
|
services.AddScoped<IUserGroupsService, UserGroupsService>();
|
||||||
services.AddScoped<IMessagesLoader, MessagesLoader>();
|
services.AddScoped<IMessagesLoader, MessagesLoader>();
|
||||||
|
|||||||
@@ -14,13 +14,13 @@ namespace Govor.API.Hubs;
|
|||||||
public class ChatsHub : Hub
|
public class ChatsHub : Hub
|
||||||
{
|
{
|
||||||
private readonly ILogger<ChatsHub> _logger;
|
private readonly ILogger<ChatsHub> _logger;
|
||||||
private readonly IMessageService _messageService;
|
private readonly IMessageCommandService _messageCommandService;
|
||||||
private readonly IUserGroupsService _userService;
|
private readonly IUserGroupsService _userService;
|
||||||
|
|
||||||
public ChatsHub(ILogger<ChatsHub> logger, IMessageService messageService, IUserGroupsService userService)
|
public ChatsHub(ILogger<ChatsHub> logger, IMessageCommandService messageCommandService, IUserGroupsService userService)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_messageService = messageService;
|
_messageCommandService = messageCommandService;
|
||||||
_userService = userService;
|
_userService = userService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ public class ChatsHub : Hub
|
|||||||
Media: request.MediaAttachments?.Select(f => new SendMedia(f.MediaId, f.EncryptedKey)) ??
|
Media: request.MediaAttachments?.Select(f => new SendMedia(f.MediaId, f.EncryptedKey)) ??
|
||||||
Array.Empty<SendMedia>());
|
Array.Empty<SendMedia>());
|
||||||
|
|
||||||
var result = await _messageService.SendMessageAsync(sendMessageParams);
|
var result = await _messageCommandService.SendMessageAsync(sendMessageParams);
|
||||||
|
|
||||||
if (!result.IsSuccess || result.Message.Id == Guid.Empty)
|
if (!result.IsSuccess || result.Message.Id == Guid.Empty)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Govor.API.Extensions;
|
using Govor.API.Extensions;
|
||||||
using Govor.API.Hubs;
|
using Govor.API.Hubs;
|
||||||
using Govor.Application.Services;
|
using Govor.Application.Services.Authentication;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
@@ -19,7 +19,7 @@ builder.Services.AddCors(options =>
|
|||||||
{
|
{
|
||||||
options.AddPolicy("AllowFrontend", policy =>
|
options.AddPolicy("AllowFrontend", policy =>
|
||||||
{
|
{
|
||||||
policy.WithOrigins("http://localhost:5000", "https://5.129.212.144:5000") // Укажите ваш публичный IP
|
policy.WithOrigins("http://localhost:5000", "https://5.129.212.144:5000")
|
||||||
.AllowAnyHeader()
|
.AllowAnyHeader()
|
||||||
.AllowAnyMethod()
|
.AllowAnyMethod()
|
||||||
.AllowCredentials();
|
.AllowCredentials();
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AutoFixture" Version="5.0.0-preview0012" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="6.0.2" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.6" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
|
||||||
|
<PackageReference Include="Moq" Version="4.20.72" />
|
||||||
|
<PackageReference Include="NUnit" Version="4.4.0-beta.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Using Include="NUnit.Framework"/>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Govor.Application\Govor.Application.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Infrastructure\Validators\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
using AutoFixture;
|
using AutoFixture;
|
||||||
using Govor.API.Services.AdminsStuff.Interfaces;
|
using Govor.API.Services.AdminsStuff.Interfaces;
|
||||||
using Govor.Application.Interfaces.AdminsStuff;
|
using Govor.Application.Infrastructure.AdminsStuff;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
using Govor.Core.Repositories.Invaites;
|
using Govor.Core.Repositories.Invaites;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services.AdminStuff;
|
namespace Govor.Application.Tests.Infrastructure.AdminsStuff;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class InvitationGeneratorTests
|
public class InvitationGeneratorTests
|
||||||
+1
-1
@@ -3,7 +3,7 @@ using Govor.Application.Infrastructure.Extensions;
|
|||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Infrastructure.Extensions;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class CurrentUserServiceTests
|
public class CurrentUserServiceTests
|
||||||
+2
-1
@@ -6,10 +6,11 @@ using Govor.API.Services.Authentication.Interfaces;
|
|||||||
using Govor.Application.Exceptions.AuthService;
|
using Govor.Application.Exceptions.AuthService;
|
||||||
using Govor.Application.Interfaces.Authentication;
|
using Govor.Application.Interfaces.Authentication;
|
||||||
using Govor.Application.Services;
|
using Govor.Application.Services;
|
||||||
|
using Govor.Application.Services.Authentication;
|
||||||
using Govor.Core.Repositories.Admins;
|
using Govor.Core.Repositories.Admins;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services.Authentication;
|
namespace Govor.Application.Tests.Services.Authentication;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class AuthServiceTests
|
public class AuthServiceTests
|
||||||
+2
-1
@@ -2,11 +2,12 @@ using System.IdentityModel.Tokens.Jwt;
|
|||||||
using AutoFixture;
|
using AutoFixture;
|
||||||
using Govor.API.Services.Authentication.Interfaces;
|
using Govor.API.Services.Authentication.Interfaces;
|
||||||
using Govor.Application.Services;
|
using Govor.Application.Services;
|
||||||
|
using Govor.Application.Services.Authentication;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services.Authentication;
|
namespace Govor.Application.Tests.Services.Authentication;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class JwtServiceTests
|
public class JwtServiceTests
|
||||||
+1
-1
@@ -8,7 +8,7 @@ using Govor.Core.Repositories.Users;
|
|||||||
using Govor.Data.Repositories.Exceptions;
|
using Govor.Data.Repositories.Exceptions;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services.Friends;
|
namespace Govor.Application.Tests.Services.Friends;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FriendRequestCommandServiceTests
|
public class FriendRequestCommandServiceTests
|
||||||
+1
-1
@@ -7,7 +7,7 @@ using Govor.Core.Repositories.Users;
|
|||||||
using Govor.Data.Repositories.Exceptions;
|
using Govor.Data.Repositories.Exceptions;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services.Friends;
|
namespace Govor.Application.Tests.Services.Friends;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FriendRequestQueryServiceTests
|
public class FriendRequestQueryServiceTests
|
||||||
+1
-1
@@ -8,7 +8,7 @@ using Govor.Core.Repositories.Users;
|
|||||||
using Govor.Data.Repositories.Exceptions;
|
using Govor.Data.Repositories.Exceptions;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services.Friends;
|
namespace Govor.Application.Tests.Services.Friends;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class FriendshipServiceTests
|
public class FriendshipServiceTests
|
||||||
+7
-7
@@ -1,7 +1,7 @@
|
|||||||
using Govor.Application.Exceptions.VerifyFriendship;
|
using Govor.Application.Exceptions.VerifyFriendship;
|
||||||
using Govor.Application.Interfaces;
|
using Govor.Application.Interfaces;
|
||||||
using Govor.Application.Interfaces.Messages.Parameters;
|
using Govor.Application.Interfaces.Messages.Parameters;
|
||||||
using Govor.Application.Services;
|
using Govor.Application.Services.Messages;
|
||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
using Govor.Core.Repositories.Groups;
|
using Govor.Core.Repositories.Groups;
|
||||||
using Govor.Core.Repositories.Messages;
|
using Govor.Core.Repositories.Messages;
|
||||||
@@ -11,18 +11,18 @@ using Govor.Data.Repositories.Exceptions;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Services.Messages;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class MessageServiceTests
|
public class MessageCommandServiceTests
|
||||||
{
|
{
|
||||||
private Mock<IMessagesRepository> _mockMessagesRepo;
|
private Mock<IMessagesRepository> _mockMessagesRepo;
|
||||||
private Mock<IUsersRepository> _mockUsersRepo;
|
private Mock<IUsersRepository> _mockUsersRepo;
|
||||||
private Mock<IGroupsRepository> _mockGroupsRepo;
|
private Mock<IGroupsRepository> _mockGroupsRepo;
|
||||||
private Mock<IVerifyFriendship> _mockVerifyFriendship;
|
private Mock<IVerifyFriendship> _mockVerifyFriendship;
|
||||||
private Mock<IPrivateChatsRepository> _mockPrivateChats;
|
private Mock<IPrivateChatsRepository> _mockPrivateChats;
|
||||||
private Mock<ILogger<MessageService>> _mockLogger;
|
private Mock<ILogger<MessageCommandService>> _mockLogger;
|
||||||
private MessageService _messageService;
|
private MessageCommandService _messageService;
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void SetUp()
|
public void SetUp()
|
||||||
@@ -32,9 +32,9 @@ public class MessageServiceTests
|
|||||||
_mockGroupsRepo = new Mock<IGroupsRepository>();
|
_mockGroupsRepo = new Mock<IGroupsRepository>();
|
||||||
_mockVerifyFriendship = new Mock<IVerifyFriendship>();
|
_mockVerifyFriendship = new Mock<IVerifyFriendship>();
|
||||||
_mockPrivateChats = new Mock<IPrivateChatsRepository>();
|
_mockPrivateChats = new Mock<IPrivateChatsRepository>();
|
||||||
_mockLogger = new Mock<ILogger<MessageService>>();
|
_mockLogger = new Mock<ILogger<MessageCommandService>>();
|
||||||
|
|
||||||
_messageService = new MessageService(
|
_messageService = new MessageCommandService(
|
||||||
_mockMessagesRepo.Object,
|
_mockMessagesRepo.Object,
|
||||||
_mockUsersRepo.Object,
|
_mockUsersRepo.Object,
|
||||||
_mockGroupsRepo.Object,
|
_mockGroupsRepo.Object,
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
using AutoFixture;
|
using AutoFixture;
|
||||||
using Govor.Application.Services;
|
using Govor.Application.Services.Authentication;
|
||||||
using Govor.Core.Infrastructure.Extensions;
|
using Govor.Core.Infrastructure.Extensions;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Services;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PasswordHasherTests
|
public class PasswordHasherTests
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using Govor.Data;
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Caching.Memory;
|
using Microsoft.Extensions.Caching.Memory;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Services;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PingHandlerServiceTests
|
public class PingHandlerServiceTests
|
||||||
+1
-1
@@ -6,7 +6,7 @@ using Govor.Core.Repositories.Groups;
|
|||||||
using Govor.Data.Repositories.Exceptions;
|
using Govor.Data.Repositories.Exceptions;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Services;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class UserGroupsServiceTests
|
public class UserGroupsServiceTests
|
||||||
+1
-1
@@ -7,7 +7,7 @@ using Govor.Data.Repositories.Exceptions;
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
||||||
namespace Govor.API.Tests.UnitTests.Services;
|
namespace Govor.Application.Tests.Services;
|
||||||
|
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class VerifyFriendshipTests
|
public class VerifyFriendshipTests
|
||||||
+1
-1
@@ -2,7 +2,7 @@ using Govor.API.Services.AdminsStuff.Interfaces;
|
|||||||
using Govor.Core.Models;
|
using Govor.Core.Models;
|
||||||
using Govor.Core.Repositories.Invaites;
|
using Govor.Core.Repositories.Invaites;
|
||||||
|
|
||||||
namespace Govor.Application.Interfaces.AdminsStuff;
|
namespace Govor.Application.Infrastructure.AdminsStuff;
|
||||||
|
|
||||||
public class InvitationGenerator(IInvitesRepository repository) : IInvitationGenerator
|
public class InvitationGenerator(IInvitesRepository repository) : IInvitationGenerator
|
||||||
{
|
{
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using Govor.Core.Models;
|
|||||||
namespace Govor.Application.Interfaces.Messages;
|
namespace Govor.Application.Interfaces.Messages;
|
||||||
|
|
||||||
// Combining IChatService and IGroupService functionalities relevant to messages
|
// Combining IChatService and IGroupService functionalities relevant to messages
|
||||||
public interface IMessageService
|
public interface IMessageCommandService
|
||||||
{
|
{
|
||||||
Task<SendMessageResult> SendMessageAsync(SendMessage messageParameters);
|
Task<SendMessageResult> SendMessageAsync(SendMessage messageParameters);
|
||||||
Task<EditMessageResult> EditMessageAsync(EditMessage messageParameters);
|
Task<EditMessageResult> EditMessageAsync(EditMessage messageParameters);
|
||||||
+1
-1
@@ -8,7 +8,7 @@ using Govor.Application.Interfaces.Authentication;
|
|||||||
using Govor.Core.Infrastructure.Validators;
|
using Govor.Core.Infrastructure.Validators;
|
||||||
using Govor.Core.Repositories.Admins;
|
using Govor.Core.Repositories.Admins;
|
||||||
|
|
||||||
namespace Govor.Application.Services;
|
namespace Govor.Application.Services.Authentication;
|
||||||
|
|
||||||
public class AuthService : IAccountService
|
public class AuthService : IAccountService
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace Govor.Application.Services;
|
namespace Govor.Application.Services.Authentication;
|
||||||
public class JwtOption
|
public class JwtOption
|
||||||
{
|
{
|
||||||
public string SecretKeу {get; set;}
|
public string SecretKeу {get; set;}
|
||||||
+1
-1
@@ -6,7 +6,7 @@ using Govor.Core.Models;
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|
||||||
namespace Govor.Application.Services;
|
namespace Govor.Application.Services.Authentication;
|
||||||
|
|
||||||
public class JwtService : IJwtService
|
public class JwtService : IJwtService
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using Govor.Core.Infrastructure.Extensions;
|
using Govor.Core.Infrastructure.Extensions;
|
||||||
|
|
||||||
namespace Govor.Application.Services;
|
namespace Govor.Application.Services.Authentication;
|
||||||
|
|
||||||
public class PasswordHasher : IPasswordHasher
|
public class PasswordHasher : IPasswordHasher
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
using Govor.Application.Interfaces;
|
using Govor.Application.Interfaces;
|
||||||
using Govor.Application.Interfaces.Medias;
|
using Govor.Application.Interfaces.Medias;
|
||||||
|
|
||||||
namespace Govor.Application.Services;
|
namespace Govor.Application.Services.Messages;
|
||||||
|
|
||||||
public class MediaService : IMediaService
|
public class MediaService : IMediaService
|
||||||
{
|
{
|
||||||
+5
-5
@@ -8,24 +8,24 @@ using Govor.Core.Repositories.PrivateChats;
|
|||||||
using Govor.Core.Repositories.Users;
|
using Govor.Core.Repositories.Users;
|
||||||
using Microsoft.Extensions.Logging;
|
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 IMessagesRepository _messagesRepository;
|
||||||
private readonly IUsersRepository _usersRepository; // For validating user recipients
|
private readonly IUsersRepository _usersRepository; // For validating user recipients
|
||||||
private readonly IGroupsRepository _groupsRepository; // For validating group recipients and fetching members
|
private readonly IGroupsRepository _groupsRepository; // For validating group recipients and fetching members
|
||||||
private readonly IPrivateChatsRepository _privateChats;
|
private readonly IPrivateChatsRepository _privateChats;
|
||||||
private readonly IVerifyFriendship _verifyFriendship; // For private messages
|
private readonly IVerifyFriendship _verifyFriendship; // For private messages
|
||||||
private readonly ILogger<MessageService> _logger;
|
private readonly ILogger<MessageCommandService> _logger;
|
||||||
|
|
||||||
public MessageService(
|
public MessageCommandService(
|
||||||
IMessagesRepository messagesRepository,
|
IMessagesRepository messagesRepository,
|
||||||
IUsersRepository usersRepository,
|
IUsersRepository usersRepository,
|
||||||
IGroupsRepository groupsRepository,
|
IGroupsRepository groupsRepository,
|
||||||
IVerifyFriendship verifyFriendship,
|
IVerifyFriendship verifyFriendship,
|
||||||
IPrivateChatsRepository privateChats,
|
IPrivateChatsRepository privateChats,
|
||||||
ILogger<MessageService> logger)
|
ILogger<MessageCommandService> logger)
|
||||||
{
|
{
|
||||||
_messagesRepository = messagesRepository;
|
_messagesRepository = messagesRepository;
|
||||||
_usersRepository = usersRepository;
|
_usersRepository = usersRepository;
|
||||||
+1
-1
@@ -4,7 +4,7 @@ using Govor.Core.Repositories.Groups;
|
|||||||
using Govor.Core.Repositories.Messages;
|
using Govor.Core.Repositories.Messages;
|
||||||
using Govor.Data.Repositories.Exceptions;
|
using Govor.Data.Repositories.Exceptions;
|
||||||
|
|
||||||
namespace Govor.Application.Services;
|
namespace Govor.Application.Services.Messages;
|
||||||
|
|
||||||
public class MessagesLoader : IMessagesLoader
|
public class MessagesLoader : IMessagesLoader
|
||||||
{
|
{
|
||||||
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Contracts", "Govor.Co
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Application", "Govor.Application\Govor.Application.csproj", "{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Application", "Govor.Application\Govor.Application.csproj", "{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Govor.Application.Tests", "Govor.Application.Tests\Govor.Application.Tests.csproj", "{F56A64DF-2938-4BE0-83F2-B86429F19259}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -55,6 +57,10 @@ Global
|
|||||||
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{F56A64DF-2938-4BE0-83F2-B86429F19259}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{F56A64DF-2938-4BE0-83F2-B86429F19259}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{F56A64DF-2938-4BE0-83F2-B86429F19259}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{F56A64DF-2938-4BE0-83F2-B86429F19259}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{15031CBD-F319-4755-BA91-B86F20BD8E37} = {4ED5259A-6FB4-4D89-8E6B-4778DC68F7D4}
|
{15031CBD-F319-4755-BA91-B86F20BD8E37} = {4ED5259A-6FB4-4D89-8E6B-4778DC68F7D4}
|
||||||
@@ -64,5 +70,6 @@ Global
|
|||||||
{E4EDB179-7EB5-468D-9C1F-0CBE2E5E459E} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776}
|
{E4EDB179-7EB5-468D-9C1F-0CBE2E5E459E} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776}
|
||||||
{4E94907F-BE20-42A6-AB15-637850FEAD11} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776}
|
{4E94907F-BE20-42A6-AB15-637850FEAD11} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776}
|
||||||
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776}
|
{FC5EDCA8-FD58-4078-8FB1-2BDBB2F6CA3E} = {114F53C1-B0AB-4BA0-9E36-0E811D1B3776}
|
||||||
|
{F56A64DF-2938-4BE0-83F2-B86429F19259} = {4ED5259A-6FB4-4D89-8E6B-4778DC68F7D4}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
Reference in New Issue
Block a user