Skip to content

[repo-assist] test: Add unit tests for BookToolQueryService - #1404

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/testing-book-tool-query-service-2bde107d6d656d3b
Draft

github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/testing-book-tool-query-service-2bde107d6d656d3b

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

BookToolQueryService backs several MCP tools used by the AI chat integration (GetChapterList, GetChapterSections, GetDirectContentUrl, GetNavigationContext, GetChapterSummary) but had no direct unit test coverage. This PR adds a focused test suite covering the service's public API.

Changes

  • Added EssentialCSharp.Web.Tests/BookToolQueryServiceTests.cs with 12 tests using Moq (matching the existing repo convention for services with mockable dependencies), covering:
    • Table-of-contents mapping and URL construction in GetChapterList
    • Section ordering and McpException on unknown chapter in GetChapterSections
    • Blank/unknown section key and success paths in GetDirectContentUrl
    • Previous/next/parent resolution in GetNavigationContext
    • Chapter-scoped guideline filtering and unknown-chapter handling in GetChapterSummary

No production code was changed.

Test Status

  • dotnet build EssentialCSharp.Web.Tests --configuration Release — ✅ succeeded, 0 warnings/errors
  • dotnet test EssentialCSharp.Web.Tests --configuration Release --no-build — 159/161 passed. The 2 pre-existing failures (CaptchaService_Verify_Success, KnownBreachedPassword_IsDetected) are unrelated integration tests that call external network services (hCaptcha, HaveIBeenPwned) unreachable from this sandboxed environment; they fail identically on main without this change.
  • dotnet format EssentialCSharp.Web.Tests --verify-no-changes — no issues reported for the new file (pre-existing formatting/naming findings in other files are unrelated to this change).

This is an automated contribution from Repo Assist. Please review before merging.

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.hcaptcha.com
  • api.pwnedpasswords.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.hcaptcha.com"
    - "api.pwnedpasswords.com"

See Network Configuration for more information.

Generated by 🌈 Repo Assist, see workflow run. Learn more.
Comment /repo-assist to run again

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@4bc8419fad05e6b032741cbfd189986700bcf71c

Adds coverage for the MCP book-tool query service, which previously had
no direct unit tests despite backing several MCP tools
(GetChapterList, GetChapterSections, GetDirectContentUrl,
GetNavigationContext, GetChapterSummary). Tests cover:
- Successful chapter listing / section lookups with ordering
- McpException thrown for unknown chapters and blank/unknown section keys
- Navigation context previous/next/parent resolution
- Guideline filtering by chapter number in chapter summaries

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@BenjaminMichaelis

Copy link
Copy Markdown
Member

/repo-assist make sure the tests are DRY and using latest and best TUnit syntax and we should be using ! unecessarily like we are now

@github-actions

Copy link
Copy Markdown
Contributor Author

Repo Assist is processing issue comment, see workflow run...

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant