mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-07-18 20:24:20 +01:00
Taken suggestions from code review and created test for ExtraRuleType.Regex instead of throwing exception there.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user