aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2020-10-17 01:58:57 -0400
committerGitHub <noreply@github.com>2020-10-17 01:58:57 -0400
commit86090ab1f65c66958c897cacd04221c537053eb3 (patch)
tree184916aaaf750c1cc100a33e69d239a5c622f1f9
parentf9bd7be74180a1ea4245f864b60d985bdf7eed75 (diff)
parent74f4affcda2c0c8e6eebb96f8173533989675e66 (diff)
Merge pull request #4317 from jellyfin/tests7
Fix AudioBookListResolver test coverage
-rw-r--r--Emby.Naming/AudioBook/AudioBookResolver.cs17
-rw-r--r--tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs21
2 files changed, 18 insertions, 20 deletions
diff --git a/Emby.Naming/AudioBook/AudioBookResolver.cs b/Emby.Naming/AudioBook/AudioBookResolver.cs
index ed53bd04fa..5807d4688c 100644
--- a/Emby.Naming/AudioBook/AudioBookResolver.cs
+++ b/Emby.Naming/AudioBook/AudioBookResolver.cs
@@ -1,3 +1,4 @@
+#nullable enable
#pragma warning disable CS1591
using System;
@@ -16,21 +17,11 @@ namespace Emby.Naming.AudioBook
_options = options;
}
- public AudioBookFileInfo ParseFile(string path)
+ public AudioBookFileInfo? Resolve(string path, bool isDirectory = false)
{
- return Resolve(path, false);
- }
-
- public AudioBookFileInfo ParseDirectory(string path)
- {
- return Resolve(path, true);
- }
-
- public AudioBookFileInfo Resolve(string path, bool isDirectory = false)
- {
- if (string.IsNullOrEmpty(path))
+ if (path.Length == 0)
{
- throw new ArgumentNullException(nameof(path));
+ throw new ArgumentException("String can't be empty.", nameof(path));
}
// TODO
diff --git a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
index 83d44721c4..673289436d 100644
--- a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
+++ b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookResolverTests.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using Emby.Naming.AudioBook;
using Emby.Naming.Common;
using Xunit;
@@ -42,16 +43,22 @@ namespace Jellyfin.Naming.Tests.AudioBook
[Theory]
[MemberData(nameof(GetResolveFileTestData))]
- public void ResolveFile_ValidFileName_Success(AudioBookFileInfo expectedResult)
+ public void Resolve_ValidFileName_Success(AudioBookFileInfo expectedResult)
{
var result = new AudioBookResolver(_namingOptions).Resolve(expectedResult.Path);
Assert.NotNull(result);
- Assert.Equal(result.Path, expectedResult.Path);
- Assert.Equal(result.Container, expectedResult.Container);
- Assert.Equal(result.ChapterNumber, expectedResult.ChapterNumber);
- Assert.Equal(result.PartNumber, expectedResult.PartNumber);
- Assert.Equal(result.IsDirectory, expectedResult.IsDirectory);
+ Assert.Equal(result!.Path, expectedResult.Path);
+ Assert.Equal(result!.Container, expectedResult.Container);
+ Assert.Equal(result!.ChapterNumber, expectedResult.ChapterNumber);
+ Assert.Equal(result!.PartNumber, expectedResult.PartNumber);
+ Assert.Equal(result!.IsDirectory, expectedResult.IsDirectory);
+ }
+
+ [Fact]
+ public void Resolve_EmptyFileName_ArgumentException()
+ {
+ Assert.Throws<ArgumentException>(() => new AudioBookResolver(_namingOptions).Resolve(string.Empty));
}
}
}