Address comments

This commit is contained in:
Bond_009 2020-04-19 18:27:07 +02:00
parent d99536e99f
commit fc3e2baccc
6 changed files with 48 additions and 8 deletions

View File

@ -4,7 +4,6 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Emby.Naming.Common;
@ -22,8 +21,7 @@ namespace Emby.Naming.Audio
public bool IsMultiPart(string path)
{
var filename = Path.GetFileName(path);
if (path.Length == 0)
if (filename.Length == 0)
{
return false;
}

View File

@ -21,7 +21,7 @@ namespace Emby.Naming.Subtitles
{
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);

View 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));
}
}
}

View 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>

View File

@ -10,6 +10,8 @@ namespace Jellyfin.Naming.Tests.Music
[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)]
@ -38,7 +40,7 @@ namespace Jellyfin.Naming.Tests.Music
[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)
public void AlbumParser_MultidiscPath_Identifies(string path, bool result)
{
var parser = new AlbumParser(_namingOptions);

View File

@ -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.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)
public void SubtitleParser_ValidFileNames_Parses(string input, string language, bool isDefault, bool isForced)
{
var parser = new SubtitleParser(_namingOptions);
@ -30,7 +30,7 @@ namespace Jellyfin.Naming.Tests.Subtitles
[Theory]
[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);
@ -38,7 +38,7 @@ namespace Jellyfin.Naming.Tests.Subtitles
}
[Fact]
public void TestEmptySubtitlesPath()
public void SubtitleParser_EmptyFileNames_ThrowsArgumentException()
{
Assert.Throws<ArgumentException>(() => new SubtitleParser(_namingOptions).ParseFile(string.Empty));
}