Skip to content

Commit

Permalink
People Overhaul (#3279)
Browse files Browse the repository at this point in the history
Co-authored-by: Robbie Davis <[email protected]>
  • Loading branch information
majora2007 and therobbiedavis authored Oct 14, 2024
1 parent 75a69de commit 3a9d9fd
Show file tree
Hide file tree
Showing 107 changed files with 16,750 additions and 1,889 deletions.
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
Loading

0 comments on commit 3a9d9fd

Please sign in to comment.