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.
This commit is contained in:
@@ -35,27 +35,8 @@ public class DetailsIslandConflictSeamTests : IDisposable
|
||||
return new ClaudeDoDbContext(opts);
|
||||
}
|
||||
|
||||
private sealed class TestDbFactory : IDbContextFactory<ClaudeDoDbContext>
|
||||
{
|
||||
private readonly Func<ClaudeDoDbContext> _create;
|
||||
public TestDbFactory(Func<ClaudeDoDbContext> create) => _create = create;
|
||||
public ClaudeDoDbContext CreateDbContext() => _create();
|
||||
}
|
||||
|
||||
private sealed class NullServiceProvider : IServiceProvider
|
||||
{
|
||||
public object? GetService(Type serviceType) => null;
|
||||
}
|
||||
|
||||
private sealed class StubNotesApi : ClaudeDo.Ui.Services.Interfaces.INotesApi
|
||||
{
|
||||
public Task<List<ClaudeDo.Ui.Services.DailyNoteDto>> ListAsync(DateOnly day) =>
|
||||
Task.FromResult(new List<ClaudeDo.Ui.Services.DailyNoteDto>());
|
||||
public Task<ClaudeDo.Ui.Services.DailyNoteDto?> AddAsync(DateOnly day, string text) =>
|
||||
Task.FromResult<ClaudeDo.Ui.Services.DailyNoteDto?>(null);
|
||||
public Task UpdateAsync(string id, string text) => Task.CompletedTask;
|
||||
public Task DeleteAsync(string id) => Task.CompletedTask;
|
||||
}
|
||||
|
||||
private sealed class ConflictApproveWorkerClient : StubWorkerClient
|
||||
{
|
||||
@@ -64,7 +45,7 @@ public class DetailsIslandConflictSeamTests : IDisposable
|
||||
Task.FromResult<MergeResultDto?>(new MergeResultDto("conflict", new[] { "a.cs" }, null));
|
||||
}
|
||||
|
||||
private DetailsIslandViewModel BuildVm(StubWorkerClient worker, IMergeCoordinator merge)
|
||||
private DetailsIslandViewModel BuildVm(StubWorkerClient worker, MergeCoordinator merge)
|
||||
{
|
||||
var factory = new TestDbFactory(NewContext);
|
||||
return new DetailsIslandViewModel(factory, worker, new NullServiceProvider(), new StubNotesApi(), merge);
|
||||
|
||||
Reference in New Issue
Block a user