mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 00:55:13 +01:00
Improved tests
This commit is contained in:
@@ -6,61 +6,43 @@ namespace Jellyfin.Naming.Tests.Music
|
||||
{
|
||||
public class MultiDiscAlbumTests
|
||||
{
|
||||
[Fact]
|
||||
public void TestMultiDiscAlbums()
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Theory]
|
||||
[InlineData("", false)]
|
||||
[InlineData(@"blah blah", false)]
|
||||
[InlineData(@"D:/music/weezer/03 Pinkerton", false)]
|
||||
[InlineData(@"D:/music/michael jackson/Bad (2012 Remaster)", false)]
|
||||
[InlineData(@"cd1", true)]
|
||||
[InlineData(@"disc18", true)]
|
||||
[InlineData(@"disk10", true)]
|
||||
[InlineData(@"vol7", true)]
|
||||
[InlineData(@"volume1", true)]
|
||||
[InlineData(@"cd 1", true)]
|
||||
[InlineData(@"disc 1", true)]
|
||||
[InlineData(@"disk 1", true)]
|
||||
[InlineData(@"disk", false)]
|
||||
[InlineData(@"disk ·", false)]
|
||||
[InlineData(@"disk a", false)]
|
||||
[InlineData(@"disk volume", false)]
|
||||
[InlineData(@"disc disc", false)]
|
||||
[InlineData(@"disk disc 6", false)]
|
||||
[InlineData(@"cd - 1", true)]
|
||||
[InlineData(@"disc- 1", true)]
|
||||
[InlineData(@"disk - 1", true)]
|
||||
[InlineData(@"Disc 01 (Hugo Wolf · 24 Lieder)", true)]
|
||||
[InlineData(@"Disc 04 (Encores and Folk Songs)", true)]
|
||||
[InlineData(@"Disc04 (Encores and Folk Songs)", true)]
|
||||
[InlineData(@"Disc 04(Encores and Folk Songs)", true)]
|
||||
[InlineData(@"Disc04(Encores and Folk Songs)", true)]
|
||||
[InlineData(@"D:/Video/MBTestLibrary/VideoTest/music/.38 special/anth/Disc 2", true)]
|
||||
[InlineData(@"[1985] Opportunities (Let's make lots of money) (1985)", false)]
|
||||
[InlineData(@"Blah 04(Encores and Folk Songs)", false)]
|
||||
public void TestMultiDiscAlbums(string path, bool result)
|
||||
{
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"blah blah"));
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"D:/music/weezer/03 Pinkerton"));
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"D:/music/michael jackson/Bad (2012 Remaster)"));
|
||||
var parser = new AlbumParser(_namingOptions);
|
||||
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"cd1"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"disc18"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"disk10"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"vol7"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"volume1"));
|
||||
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"cd 1"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"disc 1"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"disk 1"));
|
||||
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"disk"));
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"disk ·"));
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"disk a"));
|
||||
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"disk volume"));
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"disc disc"));
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"disk disc 6"));
|
||||
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"cd - 1"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"disc- 1"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"disk - 1"));
|
||||
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"Disc 01 (Hugo Wolf · 24 Lieder)"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"Disc 04 (Encores and Folk Songs)"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"Disc04 (Encores and Folk Songs)"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"Disc 04(Encores and Folk Songs)"));
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"Disc04(Encores and Folk Songs)"));
|
||||
|
||||
Assert.True(IsMultiDiscAlbumFolder(@"D:/Video/MBTestLibrary/VideoTest/music/.38 special/anth/Disc 2"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMultiDiscAlbums1()
|
||||
{
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"[1985] Opportunities (Let's make lots of money) (1985)"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestMultiDiscAlbums2()
|
||||
{
|
||||
Assert.False(IsMultiDiscAlbumFolder(@"Blah 04(Encores and Folk Songs)"));
|
||||
}
|
||||
|
||||
private bool IsMultiDiscAlbumFolder(string path)
|
||||
{
|
||||
var parser = new AlbumParser(new NamingOptions());
|
||||
|
||||
return parser.IsMultiPart(path);
|
||||
Assert.Equal(result, parser.IsMultiPart(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Emby.Naming.Common;
|
||||
using System;
|
||||
using Emby.Naming.Common;
|
||||
using Emby.Naming.Subtitles;
|
||||
using Xunit;
|
||||
|
||||
@@ -6,28 +7,19 @@ namespace Jellyfin.Naming.Tests.Subtitles
|
||||
{
|
||||
public class SubtitleParserTests
|
||||
{
|
||||
private SubtitleParser GetParser()
|
||||
{
|
||||
var options = new NamingOptions();
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
return new SubtitleParser(options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestSubtitles()
|
||||
[Theory]
|
||||
[InlineData("The Skin I Live In (2011).srt", null, false, false)]
|
||||
[InlineData("The Skin I Live In (2011).eng.srt", "eng", false, false)]
|
||||
[InlineData("The Skin I Live In (2011).eng.default.srt", "eng", true, false)]
|
||||
[InlineData("The Skin I Live In (2011).eng.forced.srt", "eng", false, true)]
|
||||
[InlineData("The Skin I Live In (2011).eng.foreign.srt", "eng", false, true)]
|
||||
[InlineData("The Skin I Live In (2011).eng.default.foreign.srt", "eng", true, true)]
|
||||
[InlineData("The Skin I Live In (2011).default.foreign.eng.srt", "eng", true, true)]
|
||||
public void TestSubtitles(string input, string language, bool isDefault, bool isForced)
|
||||
{
|
||||
Test("The Skin I Live In (2011).srt", null, false, false);
|
||||
Test("The Skin I Live In (2011).eng.srt", "eng", false, false);
|
||||
Test("The Skin I Live In (2011).eng.default.srt", "eng", true, false);
|
||||
Test("The Skin I Live In (2011).eng.forced.srt", "eng", false, true);
|
||||
Test("The Skin I Live In (2011).eng.foreign.srt", "eng", false, true);
|
||||
Test("The Skin I Live In (2011).eng.default.foreign.srt", "eng", true, true);
|
||||
Test("The Skin I Live In (2011).default.foreign.eng.srt", "eng", true, true);
|
||||
}
|
||||
|
||||
private void Test(string input, string language, bool isDefault, bool isForced)
|
||||
{
|
||||
var parser = GetParser();
|
||||
var parser = new SubtitleParser(_namingOptions);
|
||||
|
||||
var result = parser.ParseFile(input);
|
||||
|
||||
@@ -35,5 +27,20 @@ namespace Jellyfin.Naming.Tests.Subtitles
|
||||
Assert.Equal(isDefault, result.IsDefault);
|
||||
Assert.Equal(isForced, result.IsForced);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("The Skin I Live In (2011).mp4")]
|
||||
public void TestNonSubtitles(string input)
|
||||
{
|
||||
var parser = new SubtitleParser(_namingOptions);
|
||||
|
||||
Assert.Null(parser.ParseFile(input));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestEmptySubtitlesPath()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user