Files
ClaudeDo/tests/ClaudeDo.Ui.Tests/ViewModels/TasksIslandDailyPrepTests.cs
T
mika kuns 76d836a278 test: dedupe the nested test doubles into one shared file
TestDbFactory was redeclared as a private nested class in 40 test files,
NullServiceProvider and StubNotesApi in 14 each, DefaultStub in 5 — 73
declarations, all semantically identical (StubNotesApi differed only in
formatting and type qualification). They now live in TestDoubles.cs next to the
existing StubWorkerClient, which was already the shared-double pattern in this
project.
2026-08-26 10:11:58 +02:00

50 lines
1.3 KiB
C#

using ClaudeDo.Data;
using ClaudeDo.Ui.ViewModels.Islands;
using Microsoft.EntityFrameworkCore;
namespace ClaudeDo.Ui.Tests.ViewModels;
public class TasksIslandDailyPrepTests : IDisposable
{
private readonly string _dbPath;
public TasksIslandDailyPrepTests()
{
_dbPath = Path.Combine(Path.GetTempPath(), $"claudedo_tasks_prep_{Guid.NewGuid():N}.db");
using var ctx = NewContext();
ctx.Database.EnsureCreated();
}
public void Dispose()
{
try { File.Delete(_dbPath); } catch { }
try { File.Delete(_dbPath + "-wal"); } catch { }
try { File.Delete(_dbPath + "-shm"); } catch { }
}
private ClaudeDoDbContext NewContext()
{
var opts = new DbContextOptionsBuilder<ClaudeDoDbContext>()
.UseSqlite($"Data Source={_dbPath}")
.Options;
return new ClaudeDoDbContext(opts);
}
private TasksIslandViewModel NewTasksVm(StubWorkerClient stub) =>
new(new TestDbFactory(NewContext), worker: stub);
[Fact]
public async Task ClearDayCommand_calls_worker()
{
var stub = new DefaultStub();
var vm = NewTasksVm(stub);
await vm.ClearDayCommand.ExecuteAsync(null);
Assert.Equal(1, stub.ClearMyDayCalls);
}
}