Files
OpenNest/OpenNest.Server.Tests/TestDatabase.cs
T
ajandClaude Opus 5.5 a72e9eb900 test(server): share the raw SQLite helpers
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>
2026-11-01 11:23:01 -05:00

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();
}
}