feat(usability): explain deleted bookings and linked transfer undo (U10)
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using Bunit;
|
||||
using Duempelkas.Infrastructure;
|
||||
using Duempelkas.Infrastructure.Persistence;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Duempelkas.Tests;
|
||||
|
||||
internal sealed class LedgerUiFixture : IDisposable
|
||||
{
|
||||
public BunitContext Context { get; } = new();
|
||||
private readonly SqliteConnection anchor;
|
||||
private readonly string folder = Path.Combine(Path.GetTempPath(), "duempelkas-ui-" + Guid.NewGuid().ToString("N"));
|
||||
public LedgerUiFixture(bool accounts = true)
|
||||
{
|
||||
Directory.CreateDirectory(folder);
|
||||
var connection = $"Data Source=ui-{Guid.NewGuid():N};Mode=Memory;Cache=Shared";
|
||||
anchor = new SqliteConnection(connection);
|
||||
anchor.Open();
|
||||
Context.Services.AddInfrastructure(connection, folder);
|
||||
Context.JSInterop.Mode = JSRuntimeMode.Loose;
|
||||
using var db = Context.Services.GetRequiredService<IDbContextFactory<FinanceDbContext>>().CreateDbContext();
|
||||
db.Database.EnsureCreated();
|
||||
if (accounts)
|
||||
{
|
||||
db.Accounts.AddRange(new() { Name = "Barkasse", CarryoverBalance = 100m }, new() { Name = "Girokonto" });
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
public T Service<T>() where T : notnull => Context.Services.GetRequiredService<T>();
|
||||
public void Dispose() { Context.Dispose(); anchor.Dispose(); Directory.Delete(folder, true); }
|
||||
}
|
||||
Reference in New Issue
Block a user