feat: make DiscordChannelAdapter testable and add unit tests#387
Conversation
- Changed DiscordChannelAdapter constructor from sealed SocketTextChannel to ITextChannel interface - Changed SendMessageAsync return type from RestUserMessage to IUserMessage - Made DiscordChannelAdapter public so tests can instantiate it directly (InternalsVisibleTo is prohibited by FFS0051) - Added explicit Discord.Net package reference to BuildBot.Discord.Tests project - Added unit tests for Name, EnterTypingState, and SendMessageAsync Prompt: Work on pull request #387 in funfair-tech/BuildBot.
|
Implemented missing code changes in commit b44b951: changed DiscordChannelAdapter constructor from SocketTextChannel to ITextChannel, widened return type to IUserMessage, made class public (InternalsVisibleTo is prohibited by FFS0051), added explicit Discord.Net reference to test project, and added unit tests for Name, EnterTypingState, and SendMessageAsync. CI running; next cycle will continue. |
|
Code review round: fixed 4 findings — removed unnecessary IMessageChannel substitute, switched to ReturnsForAnyArgs for mock resilience, added Received(1) assertion to verify embed forwarding, and clarified CleanContent pass-through behaviour in test comment. Next cycle will continue with security review if CI is green. |
|
Code review complete — 2 confirmed findings and 1 plausible finding posted as inline comments: (1) class should be |
|
Code review round: fixed 2 findings — added null-guard on DiscordChannelAdapter constructor parameter (e6bbfa6), removed redundant test comment describing test intent (ff19af1). Note: the InternalsVisibleTo finding was withdrawn as FunFair.CodeAnalysis rule FFS0051 prohibits that pattern; making the class public is the correct approach for this project. |
… of navigating msg.Channel.Name Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…est project Discord.Net is available transitively via the ProjectReference to BuildBot.Discord.csproj, so declaring it explicitly creates version-skew risk. Prompt: Work on pull request #387 in funfair-tech/BuildBot.
|
Code review clean — fixed 2 remaining inline findings (use |
|
Security review clean — no findings. Advancing to Human Review. |
|
PR is ready for merge — marked ready for review, auto-merge enabled. Code review and security review both clean. |
Super-linter summary
All files and directories linted successfully For more information, see the GitHub Actions workflow run Powered by Super-linter |
- Changed DiscordChannelAdapter constructor from sealed SocketTextChannel to ITextChannel interface - Changed SendMessageAsync return type from RestUserMessage to IUserMessage - Made DiscordChannelAdapter public so tests can instantiate it directly (InternalsVisibleTo is prohibited by FFS0051) - Added explicit Discord.Net package reference to BuildBot.Discord.Tests project - Added unit tests for Name, EnterTypingState, and SendMessageAsync Prompt: Work on pull request #387 in funfair-tech/BuildBot.
… of navigating msg.Channel.Name Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…est project Discord.Net is available transitively via the ProjectReference to BuildBot.Discord.csproj, so declaring it explicitly creates version-skew risk. Prompt: Work on pull request #387 in funfair-tech/BuildBot.
- Changed DiscordChannelAdapter constructor from sealed SocketTextChannel to ITextChannel interface - Changed SendMessageAsync return type from RestUserMessage to IUserMessage - Made DiscordChannelAdapter public so tests can instantiate it directly (InternalsVisibleTo is prohibited by FFS0051) - Added explicit Discord.Net package reference to BuildBot.Discord.Tests project - Added unit tests for Name, EnterTypingState, and SendMessageAsync Prompt: Work on pull request #387 in funfair-tech/BuildBot.
690d2ae to
c0ee30c
Compare
… of navigating msg.Channel.Name Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…est project Discord.Net is available transitively via the ProjectReference to BuildBot.Discord.csproj, so declaring it explicitly creates version-skew risk. Prompt: Work on pull request #387 in funfair-tech/BuildBot.
- Changed DiscordChannelAdapter constructor from sealed SocketTextChannel to ITextChannel interface - Changed SendMessageAsync return type from RestUserMessage to IUserMessage - Made DiscordChannelAdapter public so tests can instantiate it directly (InternalsVisibleTo is prohibited by FFS0051) - Added explicit Discord.Net package reference to BuildBot.Discord.Tests project - Added unit tests for Name, EnterTypingState, and SendMessageAsync Prompt: Work on pull request #387 in funfair-tech/BuildBot.
… of navigating msg.Channel.Name Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…est project Discord.Net is available transitively via the ProjectReference to BuildBot.Discord.csproj, so declaring it explicitly creates version-skew risk. Prompt: Work on pull request #387 in funfair-tech/BuildBot.
c0ee30c to
22defff
Compare
- Changed DiscordChannelAdapter constructor from sealed SocketTextChannel to ITextChannel interface - Changed SendMessageAsync return type from RestUserMessage to IUserMessage - Made DiscordChannelAdapter public so tests can instantiate it directly (InternalsVisibleTo is prohibited by FFS0051) - Added explicit Discord.Net package reference to BuildBot.Discord.Tests project - Added unit tests for Name, EnterTypingState, and SendMessageAsync Prompt: Work on pull request #387 in funfair-tech/BuildBot.
… of navigating msg.Channel.Name Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…est project Discord.Net is available transitively via the ProjectReference to BuildBot.Discord.csproj, so declaring it explicitly creates version-skew risk. Prompt: Work on pull request #387 in funfair-tech/BuildBot.
22defff to
6726355
Compare
|
This PR has been worked 30 times by the automation without reaching a mergeable state. Blocking for a human to investigate. |
Prompt: Work on issue #374 in funfair-tech/BuildBot.
- Changed DiscordChannelAdapter constructor from sealed SocketTextChannel to ITextChannel interface - Changed SendMessageAsync return type from RestUserMessage to IUserMessage - Made DiscordChannelAdapter public so tests can instantiate it directly (InternalsVisibleTo is prohibited by FFS0051) - Added explicit Discord.Net package reference to BuildBot.Discord.Tests project - Added unit tests for Name, EnterTypingState, and SendMessageAsync Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…dMessageAsync test ITextChannel extends IMessageChannel, so the channel substitute already satisfies the IMessageChannel type required by message.Channel. The separate messageChannel substitute was redundant. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replaces the 11-parameter Arg.Any<>() chain with ReturnsForAnyArgs so the mock setup is resilient to future parameter additions to the Discord.Net IMessageChannel.SendMessageAsync overload. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ssageAsync The mock setup used Arg.Any<>() for all arguments so a broken adapter passing the wrong embed or text would still pass. Adding a Received(1) call verifies the channel was called with text: string.Empty and the correct embed value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The adapter always sends with text: string.Empty (embed-only), so msg.CleanContent is always "" at runtime. The test stub documents this is verifying pass-through behaviour, not a realistic value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…hannelAdapter Follows project convention (see BotService) of guarding all injected constructor parameters with ?? throw new ArgumentNullException. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lAdapterTests The comment described what the test does rather than a non-obvious why, violating the code-quality rule. The production constraint (CleanContent is always empty for embed-only messages) is retained as the sole comment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… of navigating msg.Channel.Name Prompt: Work on pull request #387 in funfair-tech/BuildBot.
…est project Discord.Net is available transitively via the ProjectReference to BuildBot.Discord.csproj, so declaring it explicitly creates version-skew risk. Prompt: Work on pull request #387 in funfair-tech/BuildBot.
6726355 to
964acef
Compare
Summary
Makes
DiscordChannelAdaptertestable by:SocketTextChannelto theITextChannelinterfaceRestUserMessagereturn type toIUserMessageinSendMessageAsync[assembly: InternalsVisibleTo("BuildBot.Discord.Tests")]so tests can instantiate the internal classDiscord.Netpackage reference to the test projectName,EnterTypingState, andSendMessageAsyncinDiscordChannelAdapterTest plan
Name_ReturnsChannelName— verifiesNamedelegates toITextChannel.NameEnterTypingState_ReturnsTypingStateFromChannel— verifiesEnterTypingState()returns theIDisposablefrom the channelSendMessageAsync_ReturnsChannelNameAndCleanContent— verifies the tuple mapping fromIUserMessageCloses #374