Add channel system unit and integration tests
Comprehensive NUnit test suite covering ChannelManager, CliChannel, TelegramChannel, DI registration, and integration scenarios. Uses Moq for mocking with test stubs for isolated unit testing.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
using Luna.Channels.Abstractions;
|
||||
using Luna.Core.Abstractions;
|
||||
|
||||
namespace Luna.Channels.Tests.Stubs;
|
||||
|
||||
public class ChannelManagerStub : IChannelManager
|
||||
{
|
||||
public ChannelManagerStub() { }
|
||||
public ChannelManagerStub(ISessionManager sessionManager) { }
|
||||
|
||||
public event EventHandler<ChannelMessageReceivedEventArgs>? MessageRouted;
|
||||
|
||||
public void RegisterChannel(IChannel channel) => throw new NotImplementedException();
|
||||
|
||||
public void UnregisterChannel(string channelId) => throw new NotImplementedException();
|
||||
|
||||
public IChannel? GetChannel(string channelId) => throw new NotImplementedException();
|
||||
|
||||
public IReadOnlyList<IChannel> GetAllChannels() => throw new NotImplementedException();
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using Luna.Channels.Abstractions;
|
||||
using Luna.Shared;
|
||||
|
||||
namespace Luna.Channels.Tests.Stubs;
|
||||
|
||||
public class CliChannelStub : IChannel
|
||||
{
|
||||
public required string ChannelId { get; init; }
|
||||
public string ChannelType => throw new NotImplementedException();
|
||||
public string DisplayName => throw new NotImplementedException();
|
||||
public bool IsConnected => throw new NotImplementedException();
|
||||
public event ChannelMessageReceivedEventHandler? MessageReceived;
|
||||
public event ChannelConnectionChangedEventHandler? ConnectionStateChanged;
|
||||
public Task SendMessageAsync(ChannelMessage message, CancellationToken cancellationToken = default) => throw new NotImplementedException();
|
||||
public Task SendStreamingMessageAsync(IAsyncEnumerable<ChatStreamUpdate> messageStream, CancellationToken cancellationToken = default) => throw new NotImplementedException();
|
||||
public void RaiseMessageReceived(object? sender, ChannelMessage message) => throw new NotImplementedException();
|
||||
|
||||
public void Dispose() => throw new NotImplementedException();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Luna.Channels.Tests.Stubs;
|
||||
|
||||
public static class ServiceCollectionExtensionsStub
|
||||
{
|
||||
extension(IServiceCollection services)
|
||||
{
|
||||
public IServiceCollection AddChannels() => services;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Luna.Channels.Abstractions;
|
||||
using Luna.Shared;
|
||||
|
||||
namespace Luna.Channels.Tests.Stubs;
|
||||
|
||||
public class TelegramChannelStub : IChannel
|
||||
{
|
||||
public string ChannelId => throw new NotImplementedException();
|
||||
public string ChannelType => throw new NotImplementedException();
|
||||
public string DisplayName => throw new NotImplementedException();
|
||||
public bool IsConnected => throw new NotImplementedException();
|
||||
|
||||
public event ChannelMessageReceivedEventHandler? MessageReceived;
|
||||
public event ChannelConnectionChangedEventHandler? ConnectionStateChanged;
|
||||
|
||||
public Task SendMessageAsync(ChannelMessage message, CancellationToken cancellationToken = default) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public Task SendStreamingMessageAsync(
|
||||
IAsyncEnumerable<ChatStreamUpdate> messageStream,
|
||||
CancellationToken cancellationToken = default) =>
|
||||
throw new NotImplementedException();
|
||||
|
||||
public void RaiseMessageReceived(object? sender, ChannelMessage message)
|
||||
{
|
||||
RaiseMessageReceived(new ChannelMessageReceivedEventArgs
|
||||
{
|
||||
Channel = this,
|
||||
Message = message
|
||||
});
|
||||
}
|
||||
|
||||
public void Dispose() => throw new NotImplementedException();
|
||||
|
||||
internal void RaiseMessageReceived(ChannelMessageReceivedEventArgs args) =>
|
||||
MessageReceived?.Invoke(this, args);
|
||||
|
||||
internal void RaiseConnectionStateChanged(ChannelConnectionEventArgs args) =>
|
||||
ConnectionStateChanged?.Invoke(this, args);
|
||||
}
|
||||
Reference in New Issue
Block a user