2022-01-04 14:52:52 -07:00
|
|
|
using Emby.Naming.Common;
|
2021-12-07 07:18:17 -07:00
|
|
|
using Emby.Server.Implementations.Library.Resolvers.TV;
|
2021-03-15 00:25:20 -07:00
|
|
|
using MediaBrowser.Controller;
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
using MediaBrowser.Controller.Entities.TV;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
using MediaBrowser.Model.Entities;
|
2021-04-21 16:23:24 -07:00
|
|
|
using MediaBrowser.Model.IO;
|
2022-01-04 14:52:52 -07:00
|
|
|
using Microsoft.Extensions.Logging;
|
2021-03-15 00:25:20 -07:00
|
|
|
using Moq;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.Server.Implementations.Tests.Library
|
|
|
|
{
|
|
|
|
public class EpisodeResolverTest
|
|
|
|
{
|
2021-12-24 10:28:27 -07:00
|
|
|
private static readonly NamingOptions _namingOptions = new();
|
2021-12-07 07:18:17 -07:00
|
|
|
|
2021-03-15 00:25:20 -07:00
|
|
|
[Fact]
|
|
|
|
public void Resolve_GivenVideoInExtrasFolder_DoesNotResolveToEpisode()
|
|
|
|
{
|
|
|
|
var parent = new Folder { Name = "extras" };
|
|
|
|
|
2022-01-04 14:52:52 -07:00
|
|
|
var episodeResolver = new EpisodeResolver(Mock.Of<ILogger<EpisodeResolver>>(), _namingOptions);
|
2021-03-15 00:25:20 -07:00
|
|
|
var itemResolveArgs = new ItemResolveArgs(
|
|
|
|
Mock.Of<IServerApplicationPaths>(),
|
|
|
|
Mock.Of<IDirectoryService>())
|
|
|
|
{
|
|
|
|
Parent = parent,
|
|
|
|
CollectionType = CollectionType.TvShows,
|
2021-11-15 07:56:02 -07:00
|
|
|
FileInfo = new FileSystemMetadata
|
2021-04-21 16:23:24 -07:00
|
|
|
{
|
|
|
|
FullName = "All My Children/Season 01/Extras/All My Children S01E01 - Behind The Scenes.mkv"
|
|
|
|
}
|
2021-03-15 00:25:20 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
Assert.Null(episodeResolver.Resolve(itemResolveArgs));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void Resolve_GivenVideoInExtrasSeriesFolder_ResolvesToEpisode()
|
|
|
|
{
|
|
|
|
var series = new Series { Name = "Extras" };
|
|
|
|
|
|
|
|
// Have to create a mock because of moq proxies not being castable to a concrete implementation
|
|
|
|
// https://github.com/jellyfin/jellyfin/blob/ab0cff8556403e123642dc9717ba778329554634/Emby.Server.Implementations/Library/Resolvers/BaseVideoResolver.cs#L48
|
2022-01-04 14:52:52 -07:00
|
|
|
var episodeResolver = new EpisodeResolverMock(Mock.Of<ILogger<EpisodeResolver>>(), _namingOptions);
|
2021-03-15 00:25:20 -07:00
|
|
|
var itemResolveArgs = new ItemResolveArgs(
|
|
|
|
Mock.Of<IServerApplicationPaths>(),
|
|
|
|
Mock.Of<IDirectoryService>())
|
|
|
|
{
|
|
|
|
Parent = series,
|
|
|
|
CollectionType = CollectionType.TvShows,
|
2021-12-07 07:18:17 -07:00
|
|
|
FileInfo = new FileSystemMetadata
|
2021-04-21 16:23:24 -07:00
|
|
|
{
|
|
|
|
FullName = "Extras/Extras S01E01.mkv"
|
|
|
|
}
|
2021-03-15 00:25:20 -07:00
|
|
|
};
|
|
|
|
Assert.NotNull(episodeResolver.Resolve(itemResolveArgs));
|
|
|
|
}
|
|
|
|
|
2022-12-14 14:03:03 -07:00
|
|
|
private sealed class EpisodeResolverMock : EpisodeResolver
|
2021-03-15 00:25:20 -07:00
|
|
|
{
|
2022-01-04 14:52:52 -07:00
|
|
|
public EpisodeResolverMock(ILogger<EpisodeResolver> logger, NamingOptions namingOptions) : base(logger, namingOptions)
|
2021-03-15 00:25:20 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-12-24 10:28:27 -07:00
|
|
|
protected override TVideoType ResolveVideo<TVideoType>(ItemResolveArgs args, bool parseName) => new();
|
2021-03-15 00:25:20 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|