mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Address comments
This commit is contained in:
parent
d99536e99f
commit
fc3e2baccc
@ -4,7 +4,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Emby.Naming.Common;
|
using Emby.Naming.Common;
|
||||||
|
|
||||||
@ -22,8 +21,7 @@ namespace Emby.Naming.Audio
|
|||||||
public bool IsMultiPart(string path)
|
public bool IsMultiPart(string path)
|
||||||
{
|
{
|
||||||
var filename = Path.GetFileName(path);
|
var filename = Path.GetFileName(path);
|
||||||
|
if (filename.Length == 0)
|
||||||
if (path.Length == 0)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ namespace Emby.Naming.Subtitles
|
|||||||
{
|
{
|
||||||
if (path.Length == 0)
|
if (path.Length == 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentException("String can't be empty.", nameof(path));
|
throw new ArgumentException("File path can't be empty.", nameof(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
var extension = Path.GetExtension(path);
|
var extension = Path.GetExtension(path);
|
||||||
|
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 FirstToUpperTest(string str, string result)
|
||||||
|
{
|
||||||
|
Assert.Equal(result, StringHelper.FirstToUpper(str));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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>
|
@ -10,6 +10,8 @@ namespace Jellyfin.Naming.Tests.Music
|
|||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("", false)]
|
[InlineData("", false)]
|
||||||
|
[InlineData("C:/", false)]
|
||||||
|
[InlineData("/home/", false)]
|
||||||
[InlineData(@"blah blah", false)]
|
[InlineData(@"blah blah", false)]
|
||||||
[InlineData(@"D:/music/weezer/03 Pinkerton", false)]
|
[InlineData(@"D:/music/weezer/03 Pinkerton", false)]
|
||||||
[InlineData(@"D:/music/michael jackson/Bad (2012 Remaster)", false)]
|
[InlineData(@"D:/music/michael jackson/Bad (2012 Remaster)", false)]
|
||||||
@ -38,7 +40,7 @@ namespace Jellyfin.Naming.Tests.Music
|
|||||||
[InlineData(@"D:/Video/MBTestLibrary/VideoTest/music/.38 special/anth/Disc 2", 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(@"[1985] Opportunities (Let's make lots of money) (1985)", false)]
|
||||||
[InlineData(@"Blah 04(Encores and Folk Songs)", false)]
|
[InlineData(@"Blah 04(Encores and Folk Songs)", false)]
|
||||||
public void TestMultiDiscAlbums(string path, bool result)
|
public void AlbumParser_MultidiscPath_Identifies(string path, bool result)
|
||||||
{
|
{
|
||||||
var parser = new AlbumParser(_namingOptions);
|
var parser = new AlbumParser(_namingOptions);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ namespace Jellyfin.Naming.Tests.Subtitles
|
|||||||
[InlineData("The Skin I Live In (2011).eng.foreign.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).eng.default.foreign.srt", "eng", true, true)]
|
||||||
[InlineData("The Skin I Live In (2011).default.foreign.eng.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)
|
public void SubtitleParser_ValidFileNames_Parses(string input, string language, bool isDefault, bool isForced)
|
||||||
{
|
{
|
||||||
var parser = new SubtitleParser(_namingOptions);
|
var parser = new SubtitleParser(_namingOptions);
|
||||||
|
|
||||||
@ -30,7 +30,7 @@ namespace Jellyfin.Naming.Tests.Subtitles
|
|||||||
|
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("The Skin I Live In (2011).mp4")]
|
[InlineData("The Skin I Live In (2011).mp4")]
|
||||||
public void TestNonSubtitles(string input)
|
public void SubtitleParser_InvalidFileNames_ReturnsNull(string input)
|
||||||
{
|
{
|
||||||
var parser = new SubtitleParser(_namingOptions);
|
var parser = new SubtitleParser(_namingOptions);
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ namespace Jellyfin.Naming.Tests.Subtitles
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestEmptySubtitlesPath()
|
public void SubtitleParser_EmptyFileNames_ThrowsArgumentException()
|
||||||
{
|
{
|
||||||
Assert.Throws<ArgumentException>(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty));
|
Assert.Throws<ArgumentException>(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user