|
|
|
@ -13,7 +13,7 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting
|
|
|
|
|
{
|
|
|
|
|
[Theory]
|
|
|
|
|
[ClassData(typeof(EpisodeBadData))]
|
|
|
|
|
public void Compare_GivenNull_ThrowsArgumentNullException(BaseItem x, BaseItem y)
|
|
|
|
|
public void Compare_GivenNull_ThrowsArgumentNullException(BaseItem? x, BaseItem? y)
|
|
|
|
|
{
|
|
|
|
|
var cmp = new AiredEpisodeOrderComparer();
|
|
|
|
|
Assert.Throws<ArgumentNullException>(() => cmp.Compare(x, y));
|
|
|
|
@ -29,152 +29,122 @@ namespace Jellyfin.Server.Implementations.Tests.Sorting
|
|
|
|
|
Assert.Equal(-expected, cmp.Compare(y, x));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class EpisodeBadData : IEnumerable<object?[]>
|
|
|
|
|
private class EpisodeBadData : TheoryData<BaseItem?, BaseItem?>
|
|
|
|
|
{
|
|
|
|
|
public IEnumerator<object?[]> GetEnumerator()
|
|
|
|
|
public EpisodeBadData()
|
|
|
|
|
{
|
|
|
|
|
yield return new object?[] { null, new Episode() };
|
|
|
|
|
yield return new object?[] { new Episode(), null };
|
|
|
|
|
Add(null, new Episode());
|
|
|
|
|
Add(new Episode(), null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class EpisodeTestData : IEnumerable<object?[]>
|
|
|
|
|
private class EpisodeTestData : TheoryData<BaseItem, BaseItem, int>
|
|
|
|
|
{
|
|
|
|
|
public IEnumerator<object?[]> GetEnumerator()
|
|
|
|
|
public EpisodeTestData()
|
|
|
|
|
{
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Movie(),
|
|
|
|
|
new Movie(),
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Movie(),
|
|
|
|
|
new Episode(),
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
// Good cases
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode(),
|
|
|
|
|
new Episode(),
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 2, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
// Good Specials
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 2 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
// Specials to Episodes
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 2 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 2 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsAfterSeasonNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 3, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsAfterSeasonNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 3, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsAfterSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 2 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
1);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
|
|
|
|
0
|
|
|
|
|
};
|
|
|
|
|
yield return new object?[]
|
|
|
|
|
{
|
|
|
|
|
0);
|
|
|
|
|
|
|
|
|
|
Add(
|
|
|
|
|
new Episode { ParentIndexNumber = 1, IndexNumber = 3 },
|
|
|
|
|
new Episode { ParentIndexNumber = 0, IndexNumber = 1, AirsBeforeSeasonNumber = 1, AirsBeforeEpisodeNumber = 2 },
|
|
|
|
|
1
|
|
|
|
|
};
|
|
|
|
|
1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|