2021-08-03 20:46:56 +00:00
|
|
|
using System;
|
2020-01-11 20:16:36 +00:00
|
|
|
using Emby.Naming.Common;
|
2020-01-11 19:25:06 +00:00
|
|
|
using Emby.Naming.Video;
|
2019-12-06 19:40:06 +00:00
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Jellyfin.Naming.Tests.Video
|
|
|
|
{
|
2020-01-11 19:25:06 +00:00
|
|
|
public sealed class CleanStringTests
|
2019-12-06 19:40:06 +00:00
|
|
|
{
|
2021-05-23 22:30:41 +00:00
|
|
|
private readonly NamingOptions _namingOptions = new NamingOptions();
|
2020-01-11 19:25:06 +00:00
|
|
|
|
|
|
|
[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("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")]
|
2021-08-03 20:46:56 +00:00
|
|
|
[InlineData("[HorribleSubs] Made in Abyss - 13 [720p].mkv", "Made in Abyss")]
|
|
|
|
[InlineData("[Tsundere] Kore wa Zombie Desu ka of the Dead [BDRip h264 1920x1080 FLAC]", "Kore wa Zombie Desu ka of the Dead")]
|
|
|
|
[InlineData("[Erai-raws] Jujutsu Kaisen - 03 [720p][Multiple Subtitle].mkv", "Jujutsu Kaisen")]
|
|
|
|
[InlineData("[OCN] 애타는 로맨스 720p-NEXT", "애타는 로맨스")]
|
|
|
|
[InlineData("[tvN] 혼술남녀.E01-E16.720p-NEXT", "혼술남녀")]
|
|
|
|
[InlineData("[tvN] 연애말고 결혼 E01~E16 END HDTV.H264.720p-WITH", "연애말고 결혼")]
|
2020-01-11 19:25:06 +00:00
|
|
|
// FIXME: [InlineData("After The Sunset - [0004].mkv", "After The Sunset")]
|
2021-03-09 00:28:21 +00:00
|
|
|
public void CleanStringTest_NeedsCleaning_Success(string input, string expectedName)
|
2020-01-11 19:25:06 +00:00
|
|
|
{
|
2021-05-23 22:30:41 +00:00
|
|
|
Assert.True(VideoResolver.TryCleanString(input, _namingOptions, out ReadOnlySpan<char> newName));
|
2021-03-09 00:28:21 +00:00
|
|
|
// TODO: compare spans when XUnit supports it
|
|
|
|
Assert.Equal(expectedName, newName.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
[InlineData(null)]
|
|
|
|
[InlineData("")]
|
|
|
|
[InlineData("Super movie(2009).mp4")]
|
|
|
|
[InlineData("[rec].mkv")]
|
|
|
|
[InlineData("American.Psycho.mkv")]
|
|
|
|
[InlineData("American Psycho.mkv")]
|
|
|
|
[InlineData("Run lola run (lola rennt) (2009).mp4")]
|
|
|
|
public void CleanStringTest_DoesntNeedCleaning_False(string? input)
|
|
|
|
{
|
2021-05-23 22:30:41 +00:00
|
|
|
Assert.False(VideoResolver.TryCleanString(input, _namingOptions, out ReadOnlySpan<char> newName));
|
2021-03-09 00:28:21 +00:00
|
|
|
Assert.True(newName.IsEmpty);
|
2019-12-06 19:40:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|