Skip to content

Commit

Permalink
Add test for GatewayReconnectException log
Browse files Browse the repository at this point in the history
  • Loading branch information
austins committed Oct 9, 2024
1 parent 16da345 commit 2af4b28
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Discord;
using Discord.WebSocket;
using DiscordTranslationBot.Commands.Logging;

namespace DiscordTranslationBot.Tests.Unit.Commands.Logging;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 2af4b28

Please sign in to comment.