Files
Govor/Govor.API.Tests/IntegrationTests/Hubs/ChatsHubTests.cs
T
Artemy be0edb0f94 Refactor user ID access in SignalR hubs and add online user tracking
Introduces IHubUserAccessor and its implementation to centralize user ID retrieval from SignalR HubCallerContext, replacing duplicated logic in ChatsHub, FriendsHub, and PresenceHub. Moves extension and mapping files to a Common directory, adds UserToUserDtoMappingAction for online status mapping, and implements OnlineUserStore with tests for tracking online users. Updates dependency injection and test code to use the new abstractions.
2025-07-23 22:21:51 +07:00

47 lines
1.4 KiB
C#

using AutoFixture;
using Govor.API.Common.SignalR.Helpers;
using Govor.API.Hubs;
using Govor.Application.Interfaces;
using Govor.Application.Interfaces.Messages;
using Microsoft.Extensions.Logging;
using Moq;
namespace Govor.API.Tests.IntegrationTests.Hubs;
[TestFixture]
public class ChatsHubTests
{
private Mock<ILogger<ChatsHub>> _loggerMock;
private Mock<IMessageCommandService> _messageServiceMock;
private Mock<IUserGroupsService> _userGroupsServiceMock;
private Mock<IHubUserAccessor> _hubUserAccessorMock;
private Fixture _fixture;
private ChatsHub _chatsHub;
[SetUp]
public void SetUp()
{
_fixture = new Fixture();
_fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList().ForEach(b => _fixture.Behaviors.Remove(b));
_fixture.Behaviors.Add(new OmitOnRecursionBehavior());
_messageServiceMock = new Mock<IMessageCommandService>();
_userGroupsServiceMock = new Mock<IUserGroupsService>();
_loggerMock = new Mock<ILogger<ChatsHub>>();
_hubUserAccessorMock = new Mock<IHubUserAccessor>();
_chatsHub = new ChatsHub(
_loggerMock.Object,
_messageServiceMock.Object,
_userGroupsServiceMock.Object,
_hubUserAccessorMock.Object
);
}
// Test for Send action
[Test]
public void SendMessage_Success()
{
}
}