Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Scanner + People Pages #3286

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion API.Tests/API.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<ItemGroup>
<Folder Include="Services\Test Data\ArchiveService\ComicInfos" />
<Folder Include="Services\Test Data\ImageService\Covers\" />
<Folder Include="Services\Test Data\ScannerService\Manga" />
</ItemGroup>

<ItemGroup>
Expand Down
43 changes: 30 additions & 13 deletions API.Tests/Extensions/QueryableExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,28 +126,45 @@ public void RestrictAgainstAgeRestriction_Tag_ShouldRestrictEverythingAboveTeen(
[InlineData(false, 1)]
public void RestrictAgainstAgeRestriction_Person_ShouldRestrictEverythingAboveTeen(bool includeUnknowns, int expectedCount)
{
var items = new List<Person>()
// Arrange
var items = new List<Person>
{
new PersonBuilder("Test", PersonRole.Character)
.WithSeriesMetadata(new SeriesMetadataBuilder().WithAgeRating(AgeRating.Teen).Build())
.Build(),
new PersonBuilder("Test", PersonRole.Character)
.WithSeriesMetadata(new SeriesMetadataBuilder().WithAgeRating(AgeRating.Unknown).Build())
.WithSeriesMetadata(new SeriesMetadataBuilder().WithAgeRating(AgeRating.Teen).Build())
.Build(),
new PersonBuilder("Test", PersonRole.Character)
.WithSeriesMetadata(new SeriesMetadataBuilder().WithAgeRating(AgeRating.X18Plus).Build())
.Build(),
CreatePersonWithSeriesMetadata("Test1", AgeRating.Teen),
CreatePersonWithSeriesMetadata("Test2", AgeRating.Unknown, AgeRating.Teen),
CreatePersonWithSeriesMetadata("Test3", AgeRating.X18Plus)
};

var filtered = items.AsQueryable().RestrictAgainstAgeRestriction(new AgeRestriction()
var ageRestriction = new AgeRestriction
{
AgeRating = AgeRating.Teen,
IncludeUnknowns = includeUnknowns
});
};

// Act
var filtered = items.AsQueryable().RestrictAgainstAgeRestriction(ageRestriction);

// Assert
Assert.Equal(expectedCount, filtered.Count());
}

private static Person CreatePersonWithSeriesMetadata(string name, params AgeRating[] ageRatings)
{
var person = new PersonBuilder(name).Build();

foreach (var ageRating in ageRatings)
{
var seriesMetadata = new SeriesMetadataBuilder().WithAgeRating(ageRating).Build();
person.SeriesMetadataPeople.Add(new SeriesMetadataPeople
{
SeriesMetadata = seriesMetadata,
Person = person,
Role = PersonRole.Character // Role is now part of the relationship
});
}

return person;
}

[Theory]
[InlineData(true, 2)]
[InlineData(false, 1)]
Expand Down
29 changes: 29 additions & 0 deletions API.Tests/Extensions/SeriesExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,35 @@ public void GetCoverImage_JustVolumes()
Assert.Equal("Volume 1 Chapter 1", series.GetCoverImage());
}

[Fact]
public void GetCoverImage_JustVolumes_ButVolume0()
{
var series = new SeriesBuilder("Test 1")
.WithFormat(MangaFormat.Archive)

.WithVolume(new VolumeBuilder("0")
.WithName("Volume 0")
.WithChapter(new ChapterBuilder(Parser.DefaultChapter)
.WithCoverImage("Volume 0")
.Build())
.Build())

.WithVolume(new VolumeBuilder("1")
.WithName("Volume 1")
.WithChapter(new ChapterBuilder(Parser.DefaultChapter)
.WithCoverImage("Volume 1")
.Build())
.Build())
.Build();

foreach (var vol in series.Volumes)
{
vol.CoverImage = vol.Chapters.MinBy(x => x.SortOrder, ChapterSortComparerDefaultFirst.Default)?.CoverImage;
}

Assert.Equal("Volume 1", series.GetCoverImage());
}

[Fact]
public void GetCoverImage_JustSpecials_WithDecimal()
{
Expand Down
Loading