Taken suggestions from code review and created test for ExtraRuleType.Regex instead of throwing exception there.

This commit is contained in:
Stepan
2020-11-12 13:16:33 +01:00
parent 496923719c
commit 3bca1181b3
5 changed files with 14 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using Emby.Naming.Common;
using Emby.Naming.Video;
using Xunit;
@@ -51,6 +51,8 @@ namespace Jellyfin.Naming.Tests.Video
[InlineData("My Movie 2013-12-09", "My Movie 2013-12-09", null)]
[InlineData("My Movie 20131209", "My Movie 20131209", null)]
[InlineData("My Movie 2013-12-09 2013", "My Movie 2013-12-09", 2013)]
[InlineData(null, null, null)]
[InlineData("", "", null)]
public void CleanDateTimeTest(string input, string expectedName, int? expectedYear)
{
input = Path.GetFileName(input);

View File

@@ -95,18 +95,14 @@ namespace Jellyfin.Naming.Tests.Video
}
}
[Fact]
public void TestExtraInfo_InvalidRuleMediaType()
{
var options = new NamingOptions { VideoExtraRules = new[] { new ExtraRule(ExtraType.Unknown, ExtraRuleType.DirectoryName, " ", MediaType.Photo) } };
Assert.Throws<InvalidOperationException>(() => GetExtraTypeParser(options).GetExtraInfo("sample.jpg"));
}
[Fact]
public void TestExtraInfo_InvalidRuleType()
{
var options = new NamingOptions { VideoExtraRules = new[] { new ExtraRule(ExtraType.Unknown, ExtraRuleType.Regex, " ", MediaType.Video) } };
Assert.Throws<InvalidOperationException>(() => GetExtraTypeParser(options).GetExtraInfo("sample.mp4"));
var rule = new ExtraRule(ExtraType.Unknown, ExtraRuleType.Regex, @"([eE]x(tra)?\.\w+)", MediaType.Video);
var options = new NamingOptions { VideoExtraRules = new[] { rule } };
var res = GetExtraTypeParser(options).GetExtraInfo("extra.mp4");
Assert.Equal(rule, res.Rule);
}
[Fact]