jellyfin/tests/Jellyfin.Naming.Tests/Video/Format3DTests.cs

75 lines
2.5 KiB
C#
Raw Normal View History

2019-12-06 19:40:06 +00:00
using Emby.Naming.Common;
using Emby.Naming.Video;
using Xunit;
namespace Jellyfin.Naming.Tests.Video
{
2020-04-21 10:11:55 +00:00
public class Format3DTests
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 TestKodiFormat3D()
{
2020-04-21 10:11:55 +00:00
Test("Super movie.3d.mp4", false, null);
Test("Super movie.3d.hsbs.mp4", true, "hsbs");
Test("Super movie.3d.sbs.mp4", true, "sbs");
Test("Super movie.3d.htab.mp4", true, "htab");
Test("Super movie.3d.tab.mp4", true, "tab");
Test("Super movie 3d hsbs.mp4", true, "hsbs");
2019-12-06 19:40:06 +00:00
}
[Fact]
public void Test3DName()
{
2021-05-23 22:30:41 +00:00
var result = VideoResolver.ResolveFile(@"C:/Users/media/Desktop/Video Test/Movies/Oblivion/Oblivion.3d.hsbs.mkv", _namingOptions);
2019-12-06 19:40:06 +00:00
Assert.Equal("hsbs", result?.Format3D);
Assert.Equal("Oblivion", result?.Name);
2019-12-06 19:40:06 +00:00
}
[Fact]
public void TestExpandedFormat3D()
{
// These were introduced for Media Browser 3
// Kodi conventions are preferred but these still need to be supported
2020-04-21 10:11:55 +00:00
Test("Super movie.3d.mp4", false, null);
Test("Super movie.3d.hsbs.mp4", true, "hsbs");
Test("Super movie.3d.sbs.mp4", true, "sbs");
Test("Super movie.3d.htab.mp4", true, "htab");
Test("Super movie.3d.tab.mp4", true, "tab");
2019-12-06 19:40:06 +00:00
2020-04-21 10:11:55 +00:00
Test("Super movie.hsbs.mp4", true, "hsbs");
Test("Super movie.sbs.mp4", true, "sbs");
Test("Super movie.htab.mp4", true, "htab");
Test("Super movie.tab.mp4", true, "tab");
Test("Super movie.sbs3d.mp4", true, "sbs3d");
Test("Super movie.3d.mvc.mp4", true, "mvc");
2019-12-06 19:40:06 +00:00
2020-04-21 10:11:55 +00:00
Test("Super movie [3d].mp4", false, null);
Test("Super movie [hsbs].mp4", true, "hsbs");
Test("Super movie [fsbs].mp4", true, "fsbs");
Test("Super movie [ftab].mp4", true, "ftab");
Test("Super movie [htab].mp4", true, "htab");
Test("Super movie [sbs3d].mp4", true, "sbs3d");
2019-12-06 19:40:06 +00:00
}
2020-04-25 13:49:53 +00:00
private void Test(string input, bool is3D, string? format3D)
2019-12-06 19:40:06 +00:00
{
2021-05-23 22:30:41 +00:00
var result = Format3DParser.Parse(input, _namingOptions);
2019-12-06 19:40:06 +00:00
Assert.Equal(is3D, result.Is3D);
if (format3D == null)
{
2021-05-23 22:30:41 +00:00
Assert.Null(result?.Format3D);
2019-12-06 19:40:06 +00:00
}
else
{
Assert.Equal(format3D, result.Format3D, true);
}
}
}
}