| name | test-preflight |
| description | Mandatory pre-flight checks for NUnit EGM test files. Use when writing, creating, or editing test files inheriting EgmTestBase. Covers: code-first rule (read files before asking), component verification via file_search, constructor signatures, mandatory using BugSweeper.Tests directive, test file placement under Tests/Features/, compilation error fix workflow, self-check checklist. Required for every test file. stages: test-implementation, test-validation |
Test Writing Pre-Flight Checks
When to Use
- Writing any new NUnit test file
- Editing an existing test file
- Fixing compilation errors in test files
- Verifying component references before outputting code
Code-First Rule
Read before asking. Every question about a constructor signature, method signature, return type, field naming convention, or StatusDatabase path constant MUST be answered by reading the relevant source file — NOT by asking the user.
MANDATORY: Component Type Verification
Before referencing ANY Provider, Controller, Facade, or Service class in generated code:
- Call
file_search with the class name to confirm the .cs file exists.
- If the file does NOT exist and you are creating it, ensure ALL consumer files reference the exact class name you chose.
- If creating both a new component AND a consumer file, verify the class name is identical across both.
File references in instruction documents may be aspirational. Always verify via file_search or list_dir.
Before Writing Any Test, Always Read
| What you need | Where to read it |
|---|
| Constructor parameters | The .cs file for that class |
| Method signatures and return types | The .cs file where the method is declared |
| StatusDatabase path constants | Tests/Shared/Constants/GGA/StatusDatabasePaths.cs |
| Field naming convention | Any existing test file — fields use camelCase, no underscore prefix |
| SetUp wiring pattern | Any existing test file's [SetUp] method |
| Orchestrator/controller composition | Tests/Features/PGO/Builders/PGOTestOrchestratorBuilder.cs |
| Free game / bonus flow patterns | Tests/Features/PGO/Services/BonusGameScreenshotService.cs |
| Reel state / visible symbols | ReelWaitService.cs, MptFacade.cs |
| Global usings | Tests/GlobalUsings.cs |
| JSON collection handling | ConfigurationStatusProvider.cs, GameFlowStatusProvider.cs |
Things You CAN Infer (Don't Ask)
- Constructor signatures — read the file
- Method return types — read the file
StatusDatabaseFacade.GetStatusValueAsync overload — takes (string path, string propertyName)
ScreenshotFacade.GetScreenshotsAsync return type — Task<Image[]>
- Field naming — camelCase, no underscore (
.editorconfig)
- Platform annotation —
System.Drawing.Image requires [SupportedOSPlatform("windows")]
TestContext.Out.WriteLine not TestContext.WriteLine (NUnit 4)
Common Constructor Signatures (Always Verify by Reading)
GameplayOrchestrator → (GameCycleController, SnippetController, GameFeatureController, CashInController, GameStatusProvider, GameFlowStatusProvider)
GameFeatureController → (GambleController, ReSpinController, WheelBonusController)
GambleController → (GameSpeedController, ButtonsFacade, GambleStatusProvider, WinCountingStatusProvider)
ReSpinController → (ButtonsFacade, GameFlowStatusProvider)
WheelBonusController → (ButtonsFacade, GameFlowStatusProvider)
GameCycleController → (GameFlowStatusProvider, ButtonsFacade, SelfPlayFacade)
CashInController → (ButtonsFacade)
SnippetController → (SaeFacade)
DenomController → (PaytableProvider, IPaytableConfiguration, ButtonsFacade)
GameSpeedController → (GameSpeedFacade)
LanguageMenuController → (ButtonsFacade)
GameRulesController → (GameRulesFacade, ButtonsFacade)
Things Worth Asking the User
- Snippet file names/paths — game-specific artefacts outside the codebase
- Business timeout values — only if not established by convention
- Ambiguous test intent — only if genuinely contradictory
- Popup / menu name strings — runtime values not in C# source; always ask
MANDATORY: using BugSweeper.Tests;
Every test file inheriting EgmTestBase MUST include using BugSweeper.Tests; as an explicit per-file using directive. EgmTestBase is not in GlobalUsings.cs and is not in any Tests.Shared.* namespace. Omitting it causes CS0246.
Required File Anatomy
namespace Tests.Features.<Feature>;
using BugSweeper.Tests;
[TestFixture]
public class MyTests : EgmTestBase
{
...
}
MANDATORY: Test File Placement
All test .cs files MUST be placed under Tests/Features/<Feature>/ — NEVER in the Tests/ root. Placing a test in the root silently disables applyTo instruction file activation.
Fixing Compilation Errors
BEFORE attempting any fix:
- Call
read_file on the failing file to get exact current content
- Identify the exact string to replace from the read output
- Call
replace_string_in_file using text copied verbatim from the read output
Never construct oldString from memory.
Self-Check Before Outputting Code