mirror of
https://github.com/RedWizardsLab/EchoHub.git
synced 2026-09-06 15:46:03 +02:00
Add comprehensive unit tests for IRC command handling and message formatting
- Implemented IrcCommandHandlerTests to cover various IRC commands including PING, JOIN, PART, and authentication scenarios. - Added IrcMessageFormatterTests to validate message formatting for different message types such as text, images, files, and audio. - Created IrcMessageTests to ensure correct parsing of IRC messages and handling of various command formats. - Introduced TestHelpers to facilitate testing with mock connections and streams, including a FakeChatService and FakeEncryptionService for simulating chat behavior.
This commit is contained in:
@@ -34,7 +34,7 @@ public sealed class IrcGatewayService : BackgroundService
|
||||
public IEnumerable<IrcClientConnection> GetConnectionsInChannel(string channelName)
|
||||
{
|
||||
return _connections.Values
|
||||
.Where(c => c.IsAuthenticated && c.JoinedChannels.Contains(channelName));
|
||||
.Where(c => c.IsAuthenticated && c.IsInChannel(channelName));
|
||||
}
|
||||
|
||||
public IEnumerable<IrcClientConnection> GetAllConnections()
|
||||
@@ -120,8 +120,9 @@ public sealed class IrcGatewayService : BackgroundService
|
||||
try
|
||||
{
|
||||
chatService = _services.GetRequiredService<IChatService>();
|
||||
var encryption = _services.GetRequiredService<IMessageEncryptionService>();
|
||||
var handler = new IrcCommandHandler(
|
||||
connection, _options, chatService, _logger);
|
||||
connection, _options, chatService, encryption, _logger);
|
||||
|
||||
await handler.RunAsync(ct);
|
||||
}
|
||||
@@ -133,7 +134,7 @@ public sealed class IrcGatewayService : BackgroundService
|
||||
{
|
||||
if (connection.IsAuthenticated)
|
||||
{
|
||||
foreach (var ch in connection.JoinedChannels.ToList())
|
||||
foreach (var ch in connection.GetJoinedChannels())
|
||||
{
|
||||
if (chatService is null) break;
|
||||
await chatService.LeaveChannelAsync(
|
||||
|
||||
Reference in New Issue
Block a user