using PageManager.Api.Data.Models; namespace PageManager.Api.Tests.Helpers; public static class BookFactory { public static Book Create( int id = 1, string title = "Test Book", int? year = 2024, string? publisher = "Test Publisher", int? pages = 300, string? description = "A test book.", string[] formats = null!, string color = "#6366f1", string[] genres = null!, string? coverUrl = null, string? isbn = null, int? hardcoverId = null) { return new Book { Id = id, Title = title, Year = year, Publisher = publisher, Pages = pages, Description = description, Formats = formats ?? ["epub"], Color = color, Genres = genres ?? ["Fiction"], CoverUrl = coverUrl, Isbn = isbn, HardcoverId = hardcoverId, BookAuthors = [], SeriesEntries = [], }; } public static Book WithAuthors(this Book book, params (int Id, string Name)[] authors) { foreach (var (id, name) in authors) { var author = new Author { Id = id, Name = name }; book.BookAuthors.Add(new BookAuthor { BookId = book.Id, AuthorId = id, Author = author, Book = book, }); } return book; } public static Book WithSeries(this Book book, int seriesId = 1, string seriesName = "Test Series", double position = 1.0, string? arc = null) { var series = new Series { Id = seriesId, Name = seriesName }; book.SeriesEntries.Add(new SeriesEntry { SeriesId = seriesId, BookId = book.Id, Series = series, Book = book, Position = position, Arc = arc, }); return book; } }