Files
elwig/Tests/E2ETests/Setup.cs
Lorenz Stechauner 34178105a7
All checks were successful
Test / Run tests (push) Successful in 2m38s
E2ETests: Use ElwigTestDB.sqlite3 instead of default
2024-07-08 13:05:21 +02:00

37 lines
1.2 KiB
C#

using Elwig.Helpers;
using System.Reflection;
namespace Tests.E2ETests {
[SetUpFixture]
public static class Setup {
private static WinAppDriver? Driver;
[OneTimeSetUp]
public static void SetupWinAppDriver() {
Driver = new();
}
[OneTimeSetUp]
public static async Task SetupDatabase() {
if (File.Exists(Utils.TestDatabasePath)) File.Delete(Utils.TestDatabasePath);
using var cnx = await AppDbContext.ConnectAsync($"Data Source=\"{Utils.TestDatabasePath}\"; Mode=ReadWriteCreate; Foreign Keys=True; Cache=Default");
await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.Create.sql");
await AppDbContext.ExecuteEmbeddedScript(cnx, Assembly.GetExecutingAssembly(), "Tests.Resources.Sql.Insert.sql");
}
[OneTimeTearDown]
public static void TeardownWinAppDriver() {
Driver?.Dispose();
}
[OneTimeTearDown]
public static void TeardownDatabase() {
try {
// FIXME not working - other process using file
File.Delete(Utils.TestDatabasePath);
} catch { }
}
}
}