@echo off
echo ========================================
echo MToolbox - Test Runner
echo ========================================
echo.
:: 1. Build entire solution (Release)
echo [1/4] Building solution...
dotnet build MToolbox.sln -c Release || goto :error
:: 2. Prepare test fixture DLL (SamplePlugin for PluginManager integration tests)
echo [2/4] Preparing test fixtures...
if not exist "src\MToolbox.Tests\TestData" mkdir "src\MToolbox.Tests\TestData"
copy /y "build\Plugins\MToolbox.Plugin.Sample.dll" "src\MToolbox.Tests\TestData\" >nul 2>&1
if %ERRORLEVEL% NEQ 0 (
echo [WARN] SamplePlugin DLL not found in build\Plugins\, skipping fixture copy.
echo PluginManager integration tests that need a real DLL will be skipped.
)
:: 3. Rebuild test project so TestData is included in output
echo [3/4] Building test project...
dotnet build src\MToolbox.Tests\MToolbox.Tests.csproj -c Release || goto :error
:: 4. Run tests with code coverage
echo [4/4] Running tests...
dotnet test src\MToolbox.Tests\MToolbox.Tests.csproj ^
-c Release ^
--no-build ^
--verbosity normal ^
--collect:"XPlat Code Coverage" ^
--results-directory build\TestResults || goto :error
echo.
echo ========================================
echo All tests passed!
echo Coverage report: build\TestResults\
echo ========================================
goto :eof
:error
echo.
echo [ERROR] Tests failed!
exit /b 1