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

46 lines
2.3 KiB
C#
Raw Normal View History

2020-01-11 13:16:36 -07:00
using System;
using Emby.Naming.Common;
2020-01-11 12:25:06 -07:00
using Emby.Naming.Video;
2019-12-06 12:40:06 -07:00
using Xunit;
namespace Jellyfin.Naming.Tests.Video
{
2020-01-11 12:25:06 -07:00
public sealed class CleanStringTests
2019-12-06 12:40:06 -07:00
{
2020-01-11 12:25:06 -07:00
private readonly NamingOptions _namingOptions = new NamingOptions();
[Theory]
[InlineData("Super movie 480p.mp4", "Super movie")]
[InlineData("Super movie 480p 2001.mp4", "Super movie")]
[InlineData("Super movie [480p].mp4", "Super movie")]
[InlineData("480 Super movie [tmdbid=12345].mp4", "480 Super movie")]
[InlineData("Super movie(2009).mp4", "Super movie(2009).mp4")]
[InlineData("Run lola run (lola rennt) (2009).mp4", "Run lola run (lola rennt) (2009).mp4")]
[InlineData(@"American.Psycho.mkv", "American.Psycho.mkv")]
[InlineData(@"American Psycho.mkv", "American Psycho.mkv")]
[InlineData(@"[rec].mkv", "[rec].mkv")]
[InlineData("Crouching.Tiger.Hidden.Dragon.4k.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.UltraHD.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.UHD.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.HDR.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.BDrip.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
[InlineData("Crouching.Tiger.Hidden.Dragon.4K.UltraHD.HDR.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
// FIXME: [InlineData("After The Sunset - [0004].mkv", "After The Sunset")]
public void CleanStringTest(string input, string expectedName)
{
2020-01-11 13:16:36 -07:00
if (new VideoResolver(_namingOptions).TryCleanString(input, out ReadOnlySpan<char> newName))
{
// TODO: compare spans when XUnit supports it
Assert.Equal(expectedName, newName.ToString());
}
else
{
Assert.Equal(expectedName, input);
}
2019-12-06 12:40:06 -07:00
}
}
}