Files
WishNinja/tests/WishNinja.Tests/TestDb.cs
T
Jim BassoandClaude Opus 4.8 7dee999759
Build & Push Docker image / test (push) Failing after 1m33s
Build & Push Docker image / docker (push) Has been skipped
Initial build: WishNinja self-hosted gift wishlist manager
ASP.NET Core Blazor (.NET 10) + EF Core/SQLite + Identity. Features:
- Wishlists & items with local image storage (upload, clipboard paste,
  or URL fetched and stored locally)
- Owner-hidden claims (enforced at the query layer) to preserve surprises
- Admin-invite-only onboarding with email-based password resets
- All state under /data; ships as a single Docker image

Includes Dockerfile, docker-compose, Gitea Actions CI (test + push image),
Unraid template, and xUnit tests (claim privacy, invite lifecycle, image validation).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-10 15:57:42 -05:00

31 lines
998 B
C#

using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using WishNinja.Data;
namespace WishNinja.Tests;
/// <summary>
/// An <see cref="IDbContextFactory{TContext}"/> backed by a single shared in-memory SQLite
/// connection, so data written by one context is visible to the next. Dispose to tear down.
/// </summary>
public sealed class TestDb : IDbContextFactory<ApplicationDbContext>, IDisposable
{
private readonly SqliteConnection _connection;
private readonly DbContextOptions<ApplicationDbContext> _options;
public TestDb()
{
_connection = new SqliteConnection("DataSource=:memory:");
_connection.Open();
_options = new DbContextOptionsBuilder<ApplicationDbContext>()
.UseSqlite(_connection)
.Options;
using var ctx = CreateDbContext();
ctx.Database.EnsureCreated();
}
public ApplicationDbContext CreateDbContext() => new(_options);
public void Dispose() => _connection.Dispose();
}