Vibe Google Analytics

This commit is contained in:
2026-06-25 18:55:04 -04:00
parent fdf8e754f5
commit 73ae3eac53
86 changed files with 53925 additions and 46039 deletions
+16 -21
View File
@@ -1,30 +1,24 @@
using System.Diagnostics;
using System.Net.Http;
namespace Tests;
[SetUpFixture]
public class TestSetup
{
private Process? _serverProcess;
private const string ServerUrl = "http://localhost:5256";
private Process? _serverProcess;
[OneTimeSetUp]
public async Task BeforeAllTests()
{
Console.WriteLine("[DEBUG_LOG] Starting Server...");
// Find solution root
var currentDir = AppContext.BaseDirectory;
while (currentDir != null && !File.Exists(Path.Combine(currentDir, "Chrono.sln")))
{
currentDir = Path.GetDirectoryName(currentDir);
}
if (currentDir == null)
{
throw new Exception("Could not find Chrono.sln to determine project path.");
}
if (currentDir == null) throw new Exception("Could not find Chrono.sln to determine project path.");
var projectPath = Path.Combine(currentDir, "Server", "Server.csproj");
@@ -40,25 +34,27 @@ public class TestSetup
};
_serverProcess = Process.Start(startInfo);
_serverProcess.OutputDataReceived += (s, e) => { if (e.Data != null) Console.WriteLine($"[SERVER OUT] {e.Data}"); };
_serverProcess.ErrorDataReceived += (s, e) => { if (e.Data != null) Console.WriteLine($"[SERVER ERR] {e.Data}"); };
_serverProcess.OutputDataReceived += (s, e) =>
{
if (e.Data != null) Console.WriteLine($"[SERVER OUT] {e.Data}");
};
_serverProcess.ErrorDataReceived += (s, e) =>
{
if (e.Data != null) Console.WriteLine($"[SERVER ERR] {e.Data}");
};
_serverProcess.BeginOutputReadLine();
_serverProcess.BeginErrorReadLine();
if (_serverProcess == null)
{
throw new Exception("Failed to start server process.");
}
if (_serverProcess == null) throw new Exception("Failed to start server process.");
// Wait for the server to be ready
using var client = new HttpClient();
var sw = Stopwatch.StartNew();
var timeout = TimeSpan.FromSeconds(30);
bool isReady = false;
var isReady = false;
while (sw.Elapsed < timeout)
{
try
{
var response = await client.GetAsync(ServerUrl);
@@ -73,14 +69,13 @@ public class TestSetup
// Wait and retry
await Task.Delay(1000);
}
}
if (!isReady)
{
_serverProcess.Kill(true);
throw new Exception($"Server did not start within {timeout.TotalSeconds} seconds.");
}
Console.WriteLine("[DEBUG_LOG] Server is ready.");
}
@@ -94,4 +89,4 @@ public class TestSetup
_serverProcess.Dispose();
}
}
}
}