2020-01-31 21:23:46 +00:00
|
|
|
|
using Emby.Naming.Common;
|
2019-12-06 19:40:06 +00:00
|
|
|
|
using Emby.Naming.Video;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
|
{
|
2020-04-21 10:11:55 +00:00
|
|
|
|
public class StubTests
|
2019-12-06 19:40:06 +00:00
|
|
|
|
{
|
2020-04-21 10:11:55 +00:00
|
|
|
|
private readonly NamingOptions _namingOptions = new NamingOptions();
|
|
|
|
|
|
2019-12-06 19:40:06 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void TestStubs()
|
|
|
|
|
{
|
|
|
|
|
Test("video.mkv", false, null);
|
|
|
|
|
Test("video.disc", true, null);
|
|
|
|
|
Test("video.dvd.disc", true, "dvd");
|
|
|
|
|
Test("video.hddvd.disc", true, "hddvd");
|
|
|
|
|
Test("video.bluray.disc", true, "bluray");
|
|
|
|
|
Test("video.brrip.disc", true, "bluray");
|
|
|
|
|
Test("video.bd25.disc", true, "bluray");
|
|
|
|
|
Test("video.bd50.disc", true, "bluray");
|
|
|
|
|
Test("video.vhs.disc", true, "vhs");
|
|
|
|
|
Test("video.hdtv.disc", true, "tv");
|
|
|
|
|
Test("video.pdtv.disc", true, "tv");
|
|
|
|
|
Test("video.dsr.disc", true, "tv");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void TestStubName()
|
|
|
|
|
{
|
|
|
|
|
var result =
|
2020-04-21 10:11:55 +00:00
|
|
|
|
new VideoResolver(_namingOptions).ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.dvd.disc");
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
2020-05-13 22:59:19 +00:00
|
|
|
|
Assert.Equal("Oblivion", result?.Name);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-05-13 22:59:19 +00:00
|
|
|
|
private void Test(string path, bool isStub, string? stubType)
|
2019-12-06 19:40:06 +00:00
|
|
|
|
{
|
2020-04-21 10:11:55 +00:00
|
|
|
|
var isStubResult = StubResolver.TryResolveFile(path, _namingOptions, out var stubTypeResult);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
2020-01-22 21:18:56 +00:00
|
|
|
|
Assert.Equal(isStub, isStubResult);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
|
2020-01-22 21:18:56 +00:00
|
|
|
|
if (isStub)
|
2019-12-06 19:40:06 +00:00
|
|
|
|
{
|
2020-01-22 21:18:56 +00:00
|
|
|
|
Assert.Equal(stubType, stubTypeResult);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-01-22 21:18:56 +00:00
|
|
|
|
Assert.Null(stubTypeResult);
|
2019-12-06 19:40:06 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|