# GitConverter.TestsApp.ConsoleApp Integration tests that exercise the ConsoleApp entry point (`Program.Run`) end-to-end using reflection. --- ## Purpose - Verify CLI parsing, argument repair, logging and host wiring that dispatches conversions to library converters. - Invoke `Program.Run` directly (do not call `Environment.Exit`) so tests can assert exit codes and console output without spawning a separate process. --- ## Key tests - Help / no-args behavior - Unknown conversion option handling - Repair of unquoted input path tokens (developer convenience) - End-to-end conversion scenarios using sample artifacts for Shapefile, CSV and GML --- ## How tests locate `Program.Run` Tests use a robust search strategy to find the ConsoleApp entry point in test runs: 1. `Type.GetType` lookup 2. `Assembly.Load` by assembly name 3. Probe `AppContext.BaseDirectory` for `GitConverter.ConsoleApp*.dll` / `.exe` 4. Walk upward from the base directory to common `bin` output locations If the `Program` type is not found the test helper throws an informative error showing probed locations. --- ## Test data - End-to-end tests expect small sample files under `TestData\` (for example `TestData\Shapefile`). - Ensure samples are copied to test output by setting `CopyToOutputDirectory=PreserveNewest` in the test project. - Tests skip gracefully when required samples are absent so CI remains non-fatal for private data. --- ## Captured output - Tests capture `Console.Out` and `Console.Error` to in-memory buffers to assert on user-facing messages. - For failing conversions (non-zero exit code) tests expect diagnostic text in the combined stdout/stderr. --- ## Running tests - In IDE: run tests from Test Explorer (ensure ConsoleApp project is built). - CLI: `dotnet test ./GitConverter.TestsApp/GitConverter.TestsApp.csproj`. - For stability on slow CI machines increase any retry/wait time helpers used by the tests. --- ## Debugging - Use the `GITCONVERTER_DEBUG_TARGET` environment variable in Debug builds to select a predefined scenario (e.g. `Shapefile1`, `Csv1`, `Gml1`) and avoid typing long CLI arguments. - To reproduce a failing test locally run the ConsoleApp with the same CLI arguments printed by the failing test. --- ## Notes & best practices - Tests are designed to be best-effort and non-destructive: they create isolated temp folders and clean them up when possible. - Keep sample artifacts small to make integration tests fast and reliable. - If CLI messages or exit codes change, update tests to reflect the new contract. --- ## Contact Open issues for test failures, missing sample data or flaky behavior. Include captured stdout/stderr from the failing test to help triage.