diff --git a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs index eb9393b0bd..14edd64926 100644 --- a/Emby.Naming/AudioBook/AudioBookFilePathParser.cs +++ b/Emby.Naming/AudioBook/AudioBookFilePathParser.cs @@ -1,6 +1,6 @@ +#nullable enable #pragma warning disable CS1591 -using System; using System.Globalization; using System.IO; using System.Text.RegularExpressions; @@ -19,12 +19,7 @@ namespace Emby.Naming.AudioBook public AudioBookFilePathParserResult Parse(string path) { - if (path == null) - { - throw new ArgumentNullException(nameof(path)); - } - - var result = new AudioBookFilePathParserResult(); + AudioBookFilePathParserResult result = default; var fileName = Path.GetFileNameWithoutExtension(path); foreach (var expression in _options.AudioBookPartsExpressions) { diff --git a/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs b/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs index e28a58db78..7bfc4479d2 100644 --- a/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs +++ b/Emby.Naming/AudioBook/AudioBookFilePathParserResult.cs @@ -1,8 +1,9 @@ +#nullable enable #pragma warning disable CS1591 namespace Emby.Naming.AudioBook { - public class AudioBookFilePathParserResult + public struct AudioBookFilePathParserResult { public int? PartNumber { get; set; } diff --git a/MediaBrowser.Controller/Extensions/StringExtensions.cs b/MediaBrowser.Controller/Extensions/StringExtensions.cs index 3cc1f328a9..182c8ef658 100644 --- a/MediaBrowser.Controller/Extensions/StringExtensions.cs +++ b/MediaBrowser.Controller/Extensions/StringExtensions.cs @@ -1,3 +1,4 @@ +#nullable enable #pragma warning disable CS1591 using System; @@ -15,11 +16,6 @@ namespace MediaBrowser.Controller.Extensions { public static string RemoveDiacritics(this string text) { - if (text == null) - { - throw new ArgumentNullException(nameof(text)); - } - var chars = Normalize(text, NormalizationForm.FormD) .Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark); diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 21f33ad190..1c90bb4e02 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -1,3 +1,4 @@ +#nullable enable #pragma warning disable CS1591 using System; @@ -9,7 +10,7 @@ namespace MediaBrowser.Controller.Library { public static class NameExtensions { - private static string RemoveDiacritics(string name) + private static string RemoveDiacritics(string? name) { if (name == null) { diff --git a/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookFileInfoTests.cs b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookFileInfoTests.cs new file mode 100644 index 0000000000..a214bc57c4 --- /dev/null +++ b/tests/Jellyfin.Naming.Tests/AudioBook/AudioBookFileInfoTests.cs @@ -0,0 +1,30 @@ +using Emby.Naming.AudioBook; +using Xunit; + +namespace Jellyfin.Naming.Tests.AudioBook +{ + public class AudioBookFileInfoTests + { + [Fact] + public void CompareTo_Same_Success() + { + var info = new AudioBookFileInfo(); + Assert.Equal(0, info.CompareTo(info)); + } + + [Fact] + public void CompareTo_Null_Success() + { + var info = new AudioBookFileInfo(); + Assert.Equal(1, info.CompareTo(null)); + } + + [Fact] + public void CompareTo_Empty_Success() + { + var info1 = new AudioBookFileInfo(); + var info2 = new AudioBookFileInfo(); + Assert.Equal(0, info1.CompareTo(info2)); + } + } +} diff --git a/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs b/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs index a2722a1753..8dfb8f8591 100644 --- a/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs +++ b/tests/Jellyfin.Naming.Tests/Video/ExtraTests.cs @@ -44,14 +44,14 @@ namespace Jellyfin.Naming.Tests.Video } [Theory] - [InlineData(ExtraType.BehindTheScenes, "behind the scenes" )] - [InlineData(ExtraType.DeletedScene, "deleted scenes" )] - [InlineData(ExtraType.Interview, "interviews" )] - [InlineData(ExtraType.Scene, "scenes" )] - [InlineData(ExtraType.Sample, "samples" )] - [InlineData(ExtraType.Clip, "shorts" )] - [InlineData(ExtraType.Clip, "featurettes" )] - [InlineData(ExtraType.Unknown, "extras" )] + [InlineData(ExtraType.BehindTheScenes, "behind the scenes")] + [InlineData(ExtraType.DeletedScene, "deleted scenes")] + [InlineData(ExtraType.Interview, "interviews")] + [InlineData(ExtraType.Scene, "scenes")] + [InlineData(ExtraType.Sample, "samples")] + [InlineData(ExtraType.Clip, "shorts")] + [InlineData(ExtraType.Clip, "featurettes")] + [InlineData(ExtraType.Unknown, "extras")] public void TestDirectories(ExtraType type, string dirName) { Test(dirName + "/300.mp4", type, _videoOptions); diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs index c771f5f4ae..6d768af890 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs @@ -10,6 +10,7 @@ namespace Jellyfin.Server.Implementations.Tests.Library [InlineData("Superman: Red Son [imdbid=tt10985510]", "imdbid", "tt10985510")] [InlineData("Superman: Red Son - tt10985510", "imdbid", "tt10985510")] [InlineData("Superman: Red Son", "imdbid", null)] + [InlineData("Superman: Red Son", "something", null)] public void GetAttributeValue_ValidArgs_Correct(string input, string attribute, string? expectedResult) { Assert.Equal(expectedResult, PathExtensions.GetAttributeValue(input, attribute));