Update to use the Theory/InlineData method to parameterize unit tests

This commit is contained in:
dtparr 2020-04-10 21:18:41 +00:00
parent 1f33c51977
commit ce86455747

View File

@ -45,44 +45,35 @@ namespace Jellyfin.Naming.Tests.Video
Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes, videoOptions); Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes, videoOptions);
} }
[Fact] [Theory]
public void TestDirectories() [InlineData(ExtraType.BehindTheScenes, "behind the scenes" )]
[InlineData(ExtraType.DeletedScene, "deleted scenes" )]
[InlineData(ExtraType.Interview, "interviews" )]
[InlineData(ExtraType.Scene, "scenes" )]
[InlineData(ExtraType.Sample, "samples" )]
[InlineData(ExtraType.Clip, "shorts" )]
[InlineData(ExtraType.Clip, "featurettes" )]
[InlineData(ExtraType.Unknown, "extras" )]
public void TestDirectories(ExtraType type, string dirName)
{ {
var videoOptions = new NamingOptions(); var videoOptions = new NamingOptions();
(ExtraType Type, string dirName)[] extraDirectoryNameTests = Test(dirName + "/300.mp4", type, videoOptions);
{ Test("300/" + dirName + "/something.mkv", type, videoOptions);
(ExtraType.BehindTheScenes, "behind the scenes" ), Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", type, videoOptions);
(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) [Theory]
{ [InlineData("gibberish")]
Test(dirName + "/300.mp4", type, videoOptions); [InlineData("not a scene")]
Test("300/" + dirName + "/something.mkv", type, videoOptions); [InlineData("The Big Short")]
Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", type, videoOptions); public void TestNonExtraDirectories(string dirName)
} {
var videoOptions = new NamingOptions();
//Test the null condition Test(dirName + "/300.mp4", null, videoOptions);
string[] nonExtraDirectoryNames = Test("300/" + dirName + "/something.mkv", null, videoOptions);
{ Test("/data/something/Movies/300/" + dirName + "/whoknows.mp4", null, videoOptions);
"gibberish", Test("/data/something/Movies/" + dirName + "/" + dirName + ".mp4", null, videoOptions);
"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] [Fact]