using ChatBot.Models.Configuration; using ChatBot.Models.Configuration.Validators; using FluentAssertions; namespace ChatBot.Tests.Configuration.Validators; public class TelegramBotSettingsValidatorTests { private readonly TelegramBotSettingsValidator _validator = new(); [Fact] public void Validate_ShouldReturnSuccess_WhenSettingsAreValid() { // Arrange var settings = new TelegramBotSettings { BotToken = "1234567890:ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijk", }; // Act var result = _validator.Validate(null, settings); // Assert result.Succeeded.Should().BeTrue(); } [Fact] public void Validate_ShouldReturnFailure_WhenBotTokenIsEmpty() { // Arrange var settings = new TelegramBotSettings { BotToken = "" }; // Act var result = _validator.Validate(null, settings); // Assert result.Succeeded.Should().BeFalse(); result.Failures.Should().Contain(f => f.Contains("Telegram bot token is required")); } [Fact] public void Validate_ShouldReturnFailure_WhenBotTokenIsTooShort() { // Arrange var settings = new TelegramBotSettings { BotToken = "1234567890:ABC", // 15 chars, too short }; // Act var result = _validator.Validate(null, settings); // Assert result.Succeeded.Should().BeFalse(); result .Failures.Should() .Contain(f => f.Contains("Telegram bot token must be at least 40 characters")); } [Theory] [InlineData(null)] [InlineData("")] [InlineData(" ")] public void Validate_ShouldReturnFailure_WhenBotTokenIsNullOrWhitespace(string? botToken) { // Arrange var settings = new TelegramBotSettings { BotToken = botToken! }; // Act var result = _validator.Validate(null, settings); // Assert result.Succeeded.Should().BeFalse(); result.Failures.Should().Contain(f => f.Contains("Telegram bot token is required")); } }