mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-02 17:11:35 -05:00
Nine server test classes opened the test database with their own identical Execute and Scalar helpers. They now import TestDatabase. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
884 B
C#
29 lines
884 B
C#
using Microsoft.Data.Sqlite;
|
|
|
|
namespace OpenNest.Server.Tests;
|
|
|
|
/// <summary>
|
|
/// Raw SQL against a test server's SQLite file, for checks the API does not expose. Import with
|
|
/// <c>using static</c>.
|
|
/// </summary>
|
|
internal static class TestDatabase
|
|
{
|
|
public static void Execute(string path, string sql)
|
|
{
|
|
using var connection = new SqliteConnection($"Data Source={path};Pooling=False");
|
|
connection.Open();
|
|
using var command = connection.CreateCommand();
|
|
command.CommandText = sql;
|
|
command.ExecuteNonQuery();
|
|
}
|
|
|
|
public static object? Scalar(string path, string sql)
|
|
{
|
|
using var connection = new SqliteConnection($"Data Source={path};Pooling=False");
|
|
connection.Open();
|
|
using var command = connection.CreateCommand();
|
|
command.CommandText = sql;
|
|
return command.ExecuteScalar();
|
|
}
|
|
}
|