Files
novelly/tests/Novelly.Api.Tests/ServiceTestFixture.cs
T
James Wampler aca26588f9
CI / build-and-push (push) Failing after 31s
CI / deploy (push) Has been skipped
Add soft delete + trash, keyboard-first web overhaul, move chapter tags to bottom
Adds SoftDelete/Trash across characters, chapters, locations, beats with a
purge schedule and Trash page. Reworks the web client for keyboard-driven
navigation (focus helpers, help overlay, keyboard.md doc). Moves the
ChapterPage tag editor to the bottom of the page to match CharacterDetailPage.
2026-08-20 16:39:09 -07:00

112 lines
5.9 KiB
C#

using Microsoft.Extensions.Options;
using Novelly.Api.Activity;
using Novelly.Api.Beats;
using Novelly.Api.Chapters;
using Novelly.Api.Characters;
using Novelly.Api.Genres;
using Novelly.Api.Locations;
using Novelly.Api.Novels;
using Novelly.Api.Questions;
using Novelly.Api.Tags;
using Novelly.Api.Trash;
using Novelly.Api.Users;
namespace Novelly.Api.Tests;
public abstract class ServiceTestFixture
{
protected TestDatabase Db { get; private set; } = null!;
protected TestUserContext UserContext { get; private set; } = null!;
protected NovelAccessService Access { get; private set; } = null!;
protected ActivityLog ActivityLog { get; private set; } = null!;
protected ActivityService Activity { get; private set; } = null!;
protected TagService Tags { get; private set; } = null!;
protected LocationService Locations { get; private set; } = null!;
protected NovelService Novels { get; private set; } = null!;
protected CharacterService Characters { get; private set; } = null!;
protected ChapterService Chapters { get; private set; } = null!;
protected ChapterDisplayNumberLookup ChapterLabels { get; private set; } = null!;
protected BeatService Beats { get; private set; } = null!;
protected CharacterArcService Arcs { get; private set; } = null!;
protected OpenQuestionService Questions { get; private set; } = null!;
protected GenreService Genres { get; private set; } = null!;
protected TrashService Trash { get; private set; } = null!;
protected TrashOptions TrashOptions { get; private set; } = null!;
protected CapturingLogger<NovelService> NovelLogs { get; private set; } = null!;
protected CapturingLogger<CharacterService> CharacterLogs { get; private set; } = null!;
protected CapturingLogger<ChapterService> ChapterLogs { get; private set; } = null!;
protected CapturingLogger<BeatService> BeatLogs { get; private set; } = null!;
protected CapturingLogger<TagService> TagLogs { get; private set; } = null!;
protected CapturingLogger<LocationService> LocationLogs { get; private set; } = null!;
protected CapturingLogger<CharacterArcService> ArcLogs { get; private set; } = null!;
protected CapturingLogger<OpenQuestionService> QuestionLogs { get; private set; } = null!;
protected CapturingLogger<GenreService> GenreLogs { get; private set; } = null!;
protected CapturingLogger<TrashService> TrashLogs { get; private set; } = null!;
[SetUp]
public void SetUpFixture()
{
Db = new TestDatabase();
UserContext = new TestUserContext();
Access = new NovelAccessService(Db.Context, UserContext, new CapturingLogger<NovelAccessService>());
ActivityLog = new ActivityLog(Db.Context, UserContext, new CapturingLogger<ActivityLog>());
Activity = new ActivityService(Db.Context, Access, new CapturingLogger<ActivityService>());
Db.Context.Users.Add(new NovellyUser
{
Id = UserContext.UserId!.Value,
UserName = "admin@novelly.test",
Email = "admin@novelly.test",
DisplayName = "Test Admin",
GlobalRole = GlobalRole.Admin
});
Db.Context.SaveChanges();
TagLogs = new CapturingLogger<TagService>();
LocationLogs = new CapturingLogger<LocationService>();
NovelLogs = new CapturingLogger<NovelService>();
CharacterLogs = new CapturingLogger<CharacterService>();
ChapterLogs = new CapturingLogger<ChapterService>();
BeatLogs = new CapturingLogger<BeatService>();
ArcLogs = new CapturingLogger<CharacterArcService>();
QuestionLogs = new CapturingLogger<OpenQuestionService>();
GenreLogs = new CapturingLogger<GenreService>();
TrashLogs = new CapturingLogger<TrashService>();
Tags = new TagService(Db.Context, Access, ActivityLog, TagLogs, new CreateTagRequestValidator(), new UpdateTagRequestValidator());
Locations = new LocationService(Db.Context, Access, ActivityLog, LocationLogs, new CreateLocationRequestValidator(), new UpdateLocationRequestValidator());
Novels = new NovelService(
Db.Context, Access, UserContext, ActivityLog, NovelLogs, new CreateNovelRequestValidator(), new UpdateNovelRequestValidator());
Characters = new CharacterService(
Db.Context, Access, Tags, ActivityLog, CharacterLogs,
new CreateCharacterRequestValidator(), new UpdateCharacterRequestValidator(), new CreateRelationshipRequestValidator(),
new LinkCharacterIdentityRequestValidator());
ChapterLabels = new ChapterDisplayNumberLookup(Db.Context);
Chapters = new ChapterService(Db.Context, Access, Tags, Locations, ChapterLabels, ActivityLog, ChapterLogs, new CreateChapterRequestValidator(), new UpdateChapterRequestValidator());
Beats = new BeatService(
Db.Context, Access, Tags, ActivityLog, BeatLogs,
new CreateBeatRequestValidator(), new UpdateBeatRequestValidator(), new ReorderBeatsRequestValidator(),
new AssignCharacterToBeatsRequestValidator(), new MoveBeatsRequestValidator());
Arcs = new CharacterArcService(
Db.Context, Access, ActivityLog, ArcLogs,
new CreateArcStageRequestValidator(), new UpdateArcStageRequestValidator(), new ReorderArcStagesRequestValidator(),
new SetArcStageBeatsRequestValidator());
Questions = new OpenQuestionService(
Db.Context, Access, ActivityLog, QuestionLogs,
new CreateOpenQuestionRequestValidator(), new UpdateOpenQuestionRequestValidator(), new ResolveOpenQuestionRequestValidator());
Genres = new GenreService(Db.Context, GenreLogs);
TrashOptions = new TrashOptions();
Trash = new TrashService(Db.Context, Access, ActivityLog, Options.Create(TrashOptions), TrashLogs);
OnSetUp();
}
protected virtual void OnSetUp()
{
}
[TearDown]
public void TearDownFixture() => Db.Dispose();
}