From 1f33c519779bd197c9d0d6ff2373cebf3a5dd3d9 Mon Sep 17 00:00:00 2001 From: dtparr Date: Wed, 8 Apr 2020 05:17:20 +0000 Subject: [PATCH] Add Unit Test for the Extras directories. Parameterize the valid extras as well as the null conditions. --- .../Jellyfin.Naming.Tests/Video/ExtraTests.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs b/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs index 1646237a0e..c2a9ef2da4 100644 --- a/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs +++ b/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs @@ -45,6 +45,46 @@ namespace Jellyfin.Naming.Tests.Video Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes, videoOptions); } + [Fact] + public void TestDirectories() + { + var videoOptions = new NamingOptions(); + + (ExtraType Type, string dirName)[] extraDirectoryNameTests = + { + (ExtraType.BehindTheScenes, "behind the scenes" ), + (ExtraType.DeletedScene, "deleted scenes" ), + (ExtraType.Interview, "interviews" ), + (ExtraType.Scene, "scenes" ), + (ExtraType.Sample, "samples" ), + (ExtraType.Clip, "shorts" ), + (ExtraType.Clip, "featurettes" ), + (ExtraType.Unknown, "extras" ), + }; + + foreach ((ExtraType type, string dirName) in extraDirectoryNameTests) + { + Test(dirName + "/300.mp4", type, videoOptions); + Test("300/" + dirName + "/something.mkv", type, videoOptions); + Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", type, videoOptions); + } + + //Test the null condition + string[] nonExtraDirectoryNames = + { + "gibberish", + "not a scene", + }; + foreach (string dirName in nonExtraDirectoryNames) + { + Test(dirName + "/300.mp4", null, videoOptions); + Test("300/" + dirName + "/something.mkv", null, videoOptions); + Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", null, videoOptions); + } + Test("/data/something/Movies/not a scene/not a scene.mp4", null, videoOptions); + Test("/data/something/Movies/The Big Short/The Big Short.mp4", null, videoOptions); + } + [Fact] public void TestSample() {