diff --git a/tests/DiscordTranslationBot.Tests.Unit/Commands/Logging/RedirectLogMessageToLoggerHandlerTests.cs b/tests/DiscordTranslationBot.Tests.Unit/Commands/Logging/RedirectLogMessageToLoggerHandlerTests.cs index 5919709..eff8809 100644 --- a/tests/DiscordTranslationBot.Tests.Unit/Commands/Logging/RedirectLogMessageToLoggerHandlerTests.cs +++ b/tests/DiscordTranslationBot.Tests.Unit/Commands/Logging/RedirectLogMessageToLoggerHandlerTests.cs @@ -1,4 +1,5 @@ using Discord; +using Discord.WebSocket; using DiscordTranslationBot.Commands.Logging; namespace DiscordTranslationBot.Tests.Unit.Commands.Logging; @@ -38,4 +39,29 @@ public async Task Handle_RedirectLogMessageToLogger_Success(LogSeverity severity logEntry.Message.Should().Be($"Discord {command.LogMessage.Source}: {command.LogMessage.Message}"); logEntry.Exception.Should().Be(command.LogMessage.Exception); } + + [Fact] + public async Task Handle_RedirectLogMessageToLogger_GatewayReconnectException_ChangesLogLevel() + { + // Arrange + var command = new RedirectLogMessageToLogger + { + LogMessage = new LogMessage( + LogSeverity.Error, + "source1", + "message1", + new GatewayReconnectException("test")) + }; + + const LogLevel expectedLevel = LogLevel.Information; + + // Act + await _sut.Handle(command, CancellationToken.None); + + // Assert + var logEntry = _logger.Entries[0]; + logEntry.LogLevel.Should().Be(expectedLevel); + logEntry.Message.Should().Be($"Discord {command.LogMessage.Source}: {command.LogMessage.Message}"); + logEntry.Exception.Should().Be(command.LogMessage.Exception); + } }