mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-22 10:04:44 +01:00
19
tests/Jellyfin.Model.Tests/Extensions/StringHelperTests.cs
Normal file
19
tests/Jellyfin.Model.Tests/Extensions/StringHelperTests.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using MediaBrowser.Model.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace Jellyfin.Model.Tests.Extensions
|
||||
{
|
||||
public class StringHelperTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData("", "")]
|
||||
[InlineData("banana", "Banana")]
|
||||
[InlineData("Banana", "Banana")]
|
||||
[InlineData("ä", "Ä")]
|
||||
public void StringHelper_ValidArgs_Success(string input, string expectedResult)
|
||||
{
|
||||
Assert.Equal(expectedResult, StringHelper.FirstToUpper(input));
|
||||
}
|
||||
}
|
||||
}
|
||||
21
tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj
Normal file
21
tests/Jellyfin.Model.Tests/Jellyfin.Model.Tests.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.2.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../MediaBrowser.Model/MediaBrowser.Model.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -6,61 +6,45 @@ namespace Jellyfin.Naming.Tests.Music
|
||||
{
|
||||
public class MultiDiscAlbumTests
|
||||
{
|
||||
[Fact]
|
||||
public void TestMultiDiscAlbums()
|
||||
private readonly NamingOptions _namingOptions = new NamingOptions();
|
||||
|
||||
[Theory]
|
||||
[InlineData("", false)]
|
||||
[InlineData("C:/", false)]
|
||||
[InlineData("/home/", 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 AlbumParser_MultidiscPath_Identifies(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 SubtitleParser_ValidFileName_Parses(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 SubtitleParser_InvalidFileName_ReturnsNull(string input)
|
||||
{
|
||||
var parser = new SubtitleParser(_namingOptions);
|
||||
|
||||
Assert.Null(parser.ParseFile(input));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SubtitleParser_EmptyFileName_ThrowsArgumentException()
|
||||
{
|
||||
Assert.Throws<ArgumentException>(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user