Fix tests

This commit is contained in:
Zoe Roux 2023-03-14 00:15:19 +09:00
parent da17fc3e6d
commit 4b7f59e2e9
2 changed files with 10 additions and 11 deletions

View File

@ -68,8 +68,7 @@ namespace Kyoo.Core.Controllers
string libraryPath = (await _libraryManager.GetAll<Library>()) string libraryPath = (await _libraryManager.GetAll<Library>())
.SelectMany(x => x.Paths) .SelectMany(x => x.Paths)
.Where(path.StartsWith) .Where(path.StartsWith)
.OrderByDescending(x => x.Length) .MaxBy(x => x.Length);
.FirstOrDefault();
return path[(libraryPath?.Length ?? 0)..]; return path[(libraryPath?.Length ?? 0)..];
} }

View File

@ -57,7 +57,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task EpisodeIdentification() public async Task EpisodeIdentification()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo/Library/"}}
}); });
@ -77,7 +77,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task EpisodeIdentificationWithoutLibraryTrailingSlash() public async Task EpisodeIdentificationWithoutLibraryTrailingSlash()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo/Library"}} new Library {Paths = new [] {"/kyoo/Library"}}
}); });
@ -97,7 +97,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task EpisodeIdentificationMultiplePaths() public async Task EpisodeIdentificationMultiplePaths()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });
@ -117,7 +117,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task AbsoluteEpisodeIdentification() public async Task AbsoluteEpisodeIdentification()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });
@ -137,7 +137,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task MovieEpisodeIdentification() public async Task MovieEpisodeIdentification()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });
@ -158,7 +158,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task InvalidEpisodeIdentification() public async Task InvalidEpisodeIdentification()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });
@ -168,7 +168,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task SubtitleIdentification() public async Task SubtitleIdentification()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });
@ -184,7 +184,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task SubtitleIdentificationUnknownCodec() public async Task SubtitleIdentificationUnknownCodec()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });
@ -200,7 +200,7 @@ namespace Kyoo.Tests.Identifier
[Fact] [Fact]
public async Task InvalidSubtitleIdentification() public async Task InvalidSubtitleIdentification()
{ {
_manager.Setup(x => x.GetAll(null, new Sort<Library>(), default)).ReturnsAsync(new[] _manager.Setup(x => x.GetAll<Library>(null, default, default)).ReturnsAsync(new[]
{ {
new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}} new Library {Paths = new [] {"/kyoo", "/kyoo/Library/"}}
}); });