Newer
Older
percord / extra / admin-api / Utilities / Spacebar.AdminApi.PrepareTestData / Program.cs
@Emma [it/its]@Rory& Emma [it/its]@Rory& on 5 Oct 788 bytes Local changes
// See https://aka.ms/new-console-template for more information

using ArcaneLibs;
using Spacebar.AdminApi.PrepareTestData.TestDataTypes;

Console.WriteLine("Hello, World!");
var tests = ClassCollector<ITestData>.ResolveFromAllAccessibleAssemblies();
foreach (var test in tests) {
    Console.WriteLine(test.Name);
}

Console.Write("Enter test type to run: ");
var testType = Console.ReadLine();
var testToRun = tests.FirstOrDefault(t => t.Name == testType);
var runMethod = testToRun?.GetMethod("Run");

if (runMethod != null) {
    Console.WriteLine($"Running test {testToRun.FullName}...");
    var task = runMethod.Invoke(testToRun, null) as Task;
    await task!;
    Console.WriteLine($"Test {testToRun.FullName} completed.");
} else {
    Console.WriteLine("Test not found.");
}