using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; using Luna.Configuration; using Luna.Configuration.Extensions; namespace Luna.Channels.Tests; [TestFixture] [Category("Unit")] public class TelegramOptionsTests { [Test] public void BotToken_Binds_From_Configuration() { var config = new ConfigurationBuilder() .AddInMemoryCollection(new Dictionary { ["Channels:Telegram:BotToken"] = "test-token" }) .Build(); var services = new ServiceCollection(); services.AddSingleton(config); services.AddTelegramOptions(); var provider = services.BuildServiceProvider(); var options = provider.GetRequiredService>().Value; Assert.That(options.BotToken, Is.EqualTo("test-token")); } [Test] public void Validation_Fails_When_BotToken_Missing() { var config = new ConfigurationBuilder().Build(); var services = new ServiceCollection(); services.AddSingleton(config); services.AddTelegramOptions(); var provider = services.BuildServiceProvider(); Assert.That( () => provider.GetRequiredService>().Value, Throws.InstanceOf()); } [Test] public void PollingTimeoutSeconds_Defaults_To_30() { var options = new TelegramOptions { BotToken = "x" }; Assert.That(options.PollingTimeoutSeconds, Is.EqualTo(30)); } [Test] public void AllowedUserIds_Defaults_To_Empty() { var options = new TelegramOptions { BotToken = "x" }; Assert.That(options.AllowedUserIds, Is.Empty); } }