diff --git a/CHANGELOG.md b/CHANGELOG.md index 54f60b33..9b022b13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ Please ADD ALL Changes to the UNRELEASED SECTION and not a specific release - BuildBot.Json.Tests: new test project covering BuildBot.Json at 100% line and branch coverage - BuildBot.ServiceModel.Tests: Added test coverage for all types in BuildBot.ServiceModel - BuildBot.Discord.Tests: Added unit tests to increase code coverage to 100% +- BotService null-guard branch coverage test ### Fixed - Suppress known Scriban 6.2.0 vulnerabilities pending upgrade - SnsMessage: Token property was never populated from the constructor argument diff --git a/src/BuildBot.Discord.Tests/Services/BotServiceTests.cs b/src/BuildBot.Discord.Tests/Services/BotServiceTests.cs index 426952cc..97fb6976 100644 --- a/src/BuildBot.Discord.Tests/Services/BotServiceTests.cs +++ b/src/BuildBot.Discord.Tests/Services/BotServiceTests.cs @@ -1,4 +1,5 @@ using System; +using System.Reflection; using System.Threading; using System.Threading.Tasks; using BuildBot.Discord.Models; @@ -105,4 +106,17 @@ await bot.Received(1) ); } } + + [Fact] + public void Constructor_ThrowsArgumentNullException_WhenBotIsNull() + { + ConstructorInfo? ctor = typeof(BotService).GetConstructor( + [typeof(IDiscordBot), typeof(IMessageChannel), typeof(IMessageChannel)] + ); + Assert.NotNull(ctor); + + TargetInvocationException ex = Assert.Throws(() => ctor.Invoke([null, null, null])); + ArgumentNullException ane = Assert.IsType(ex.InnerException); + Assert.Equal(expected: "bot", actual: ane.ParamName); + } }