test(discord): Add null-guard branch coverage for BotService constructor#377
Conversation
|
[Code Review — Pre-existing gap] |
- Use GetConstructor with explicit parameter types instead of Assert.Single on GetConstructors(), avoiding confusing failure messages if a second constructor is ever added - Remove unnecessary MessageChannel allocations — the constructor throws before touching the channel parameters, so null suffices for those args - Assert ParamName == "bot" on the caught ArgumentNullException so a mis-targeted guard is detected rather than silently passing Prompt: Work on pull request #377 in funfair-tech/BuildBot.
- Use GetConstructor with explicit parameter types instead of Assert.Single on GetConstructors(), avoiding confusing failure messages if a second constructor is ever added - Remove unnecessary MessageChannel allocations — the constructor throws before touching the channel parameters, so null suffices for those args - Assert ParamName == "bot" on the caught ArgumentNullException so a mis-targeted guard is detected rather than silently passing Prompt: Work on pull request #377 in funfair-tech/BuildBot.
b04c00f to
c2aa353
Compare
- Use GetConstructor with explicit parameter types instead of Assert.Single on GetConstructors(), avoiding confusing failure messages if a second constructor is ever added - Remove unnecessary MessageChannel allocations — the constructor throws before touching the channel parameters, so null suffices for those args - Assert ParamName == "bot" on the caught ArgumentNullException so a mis-targeted guard is detected rather than silently passing Prompt: Work on pull request #377 in funfair-tech/BuildBot.
c2aa353 to
0e24809
Compare
…nstructor Add `?? throw ArgumentNullException` guards for botMessageChannel and botReleaseMessageChannel — they were assigned without guards and would cause a NullReferenceException deep in Rx internals if passed null. Add corresponding constructor tests to cover both new guards. Prompt: Work on pull request #377 in funfair-tech/BuildBot.
…structor Prompt: Work on pull request #377 in funfair-tech/BuildBot.
|
Fixed in ee1e59b — added |
Replace three structurally identical Constructor_ThrowsArgumentNullException_When* [Fact] methods with a single [Theory] + [MemberData] test, using an index to select which parameter is null. Removes the GetConstructor call duplicated verbatim three times and satisfies the project rule requiring parameterised tests over duplicated methods. Prompt: Work on pull request #377 in funfair-tech/BuildBot.
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
|
All work complete. Summary of changes on this PR:
Code review and security review both passed clean. Auto-merge enabled. |
Adds a reflection-based test to cover the null-bot argument guard in BotService, bringing BotService to 100% line and branch coverage. The null! operator cannot be used directly due to the NX0002 analyser rule, so the constructor is invoked via reflection. Prompt: Work on issue #356 in funfair-tech/BuildBot. Closes #356
- Use GetConstructor with explicit parameter types instead of Assert.Single on GetConstructors(), avoiding confusing failure messages if a second constructor is ever added - Remove unnecessary MessageChannel allocations — the constructor throws before touching the channel parameters, so null suffices for those args - Assert ParamName == "bot" on the caught ArgumentNullException so a mis-targeted guard is detected rather than silently passing Prompt: Work on pull request #377 in funfair-tech/BuildBot.
…nstructor Add `?? throw ArgumentNullException` guards for botMessageChannel and botReleaseMessageChannel — they were assigned without guards and would cause a NullReferenceException deep in Rx internals if passed null. Add corresponding constructor tests to cover both new guards. Prompt: Work on pull request #377 in funfair-tech/BuildBot.
…structor Prompt: Work on pull request #377 in funfair-tech/BuildBot.
Replace three structurally identical Constructor_ThrowsArgumentNullException_When* [Fact] methods with a single [Theory] + [MemberData] test, using an index to select which parameter is null. Removes the GetConstructor call duplicated verbatim three times and satisfies the project rule requiring parameterised tests over duplicated methods. Prompt: Work on pull request #377 in funfair-tech/BuildBot.
bf6ec38 to
3f41659
Compare
|
Rebased the branch onto |
|
All CI checks pass and auto-merge is enabled. The PR is currently blocked on |
|
Status update (2026-06-27): All CI checks continue to pass. Workflow board updated to Human Review. Auto-merge remains enabled and is waiting for a human approval to satisfy the branch-protection |
|
Status check (2026-06-27): No new activity to action. All CI checks pass, code review and security review both passed clean, auto-merge remains enabled, and the workflow board is confirmed at Human Review. The PR is waiting for a human approval to satisfy the branch-protection |
Summary
bot == nullguard inBotServiceconstructor, bringingBotServiceto 100% line and branch coverage.null!directly, so the constructor is invoked viaConstructorInfo.Invokewith a null argument instead.Coverage status after this PR
Remaining gaps in
BuildBot.Discord(DiscordChannelAdapterand the live-infrastructure methods ofDiscordSocketClientAdapter) are infrastructure-dependent and tracked in issue #374.Closes #356
Test plan
BotServicereaches 100% line and branch coveragedotnet buildcheckpasses with no errors