Instruction file imported from john72831/JClaw (
.github/instructions/tests-dotnet-conventions.instructions.md). Copyright stays with the author.
.NET Test Conventions
- Prefer direct xUnit Facts with explicit arrange, act, and assert flow. Keep each test focused on one behavior or one regression path.
- Use Microsoft.Extensions.Options.Options.Create for configuration objects instead of building a full host or configuration pipeline.
- Prefer small in-file fakes over heavy mocking frameworks. For HTTP clients, use custom HttpMessageHandler test doubles that assert headers, retries, and request sequencing.
- Repository tests should create a unique temporary SQLite file per test, call InitializeAsync, and clean up the file in finally blocks.
- When behavior depends on chat scope, always cover the ChatType plus ChatId boundary. Do not collapse shared chat behavior back to direct user assumptions.
- When adding schema or migration behavior, include at least one test that exercises legacy-state upgrade or backward-compatible initialization.
- When changing LINE messaging, token refresh, or resilience behavior, add assertions for the risky branch such as 401 refresh, retry key reuse, or circuit-related failure handling.
- Prefer asserting concrete persisted values, outbound request details, and task/member metadata over vague success-only assertions.
- Keep test helper types private and local to the test file unless multiple files already share the same helper.