56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
using MangaReader.Core.Common;
|
|
using MangaReader.Core.Data;
|
|
using MangaReader.Core.Metadata;
|
|
using MangaReader.Core.Pipeline;
|
|
using MangaReader.Tests.Utilities;
|
|
using Shouldly;
|
|
|
|
namespace MangaReader.Tests.Pipeline;
|
|
|
|
public class MangaPipelineTests(TestDbContextFactory factory) : IClassFixture<TestDbContextFactory>
|
|
{
|
|
[Fact]
|
|
public async Task RunAsync_SavesMangaTitlesChaptersGenres()
|
|
{
|
|
using MangaContext context = factory.CreateContext();
|
|
var pipeline = new MangaPipeline(context);
|
|
|
|
var sourceManga = new SourceManga
|
|
{
|
|
Title = "Fullmetal Alchemist",
|
|
AlternateTitles =
|
|
[
|
|
new()
|
|
{
|
|
Title = "Hagane no Renkinjutsushi",
|
|
Language = Language.Romaji
|
|
}
|
|
],
|
|
Genres = ["Action", "Adventure"],
|
|
Chapters =
|
|
[
|
|
new()
|
|
{
|
|
Number = 1,
|
|
Title = "The Two Alchemists",
|
|
Volume = 1,
|
|
Url = string.Empty
|
|
}
|
|
]
|
|
};
|
|
|
|
MangaPipelineRequest request = new()
|
|
{
|
|
SourceName = "MySource",
|
|
SourceUrl = "https://wwww.mymangasource.org/my-manga",
|
|
SourceManga = sourceManga
|
|
};
|
|
|
|
await pipeline.RunAsync(request);
|
|
|
|
context.Mangas.ShouldHaveSingleItem();
|
|
context.MangaTitles.ShouldHaveSingleItem();
|
|
context.Genres.Count().ShouldBe(2);
|
|
context.MangaChapters.ShouldHaveSingleItem();
|
|
}
|
|
} |