Bladeren bron

Fix tests

Bond_009 1 jaar geleden
bovenliggende
commit
7bf831da62

+ 1 - 1
tests/Jellyfin.Api.Tests/Controllers/ImageControllerTests.cs

@@ -27,7 +27,7 @@ public static class ImageControllerTests
     [InlineData(null)]
     [InlineData(null)]
     [InlineData("")]
     [InlineData("")]
     [InlineData("text/html")]
     [InlineData("text/html")]
-    public static void TryGetImageExtensionFromContentType_InValid_False(string contentType)
+    public static void TryGetImageExtensionFromContentType_InValid_False(string? contentType)
     {
     {
         Assert.False(ImageController.TryGetImageExtensionFromContentType(contentType, out var ex));
         Assert.False(ImageController.TryGetImageExtensionFromContentType(contentType, out var ex));
         Assert.Null(ex);
         Assert.Null(ex);

+ 15 - 25
tests/Jellyfin.Extensions.Tests/CopyToExtensionsTests.cs

@@ -8,20 +8,18 @@ namespace Jellyfin.Extensions.Tests
     {
     {
         public static TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>> CopyTo_Valid_Correct_TestData()
         public static TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>> CopyTo_Valid_Correct_TestData()
         {
         {
-            var data = new TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>>();
-
-            data.Add(
-                new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, 0, new[] { 0, 1, 2, 3, 4, 5 });
-
-            data.Add(
-                new[] { 0, 1, 2 }, new[] { 5, 4, 3, 2, 1, 0 }, 2, new[] { 5, 4, 0, 1, 2, 0 } );
+            var data = new TheoryData<IReadOnlyList<int>, IList<int>, int, IList<int>>
+            {
+                { new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, 0, new[] { 0, 1, 2, 3, 4, 5 } },
+                { new[] { 0, 1, 2 }, new[] { 5, 4, 3, 2, 1, 0 }, 2, new[] { 5, 4, 0, 1, 2, 0 } }
+            };
 
 
             return data;
             return data;
         }
         }
 
 
         [Theory]
         [Theory]
         [MemberData(nameof(CopyTo_Valid_Correct_TestData))]
         [MemberData(nameof(CopyTo_Valid_Correct_TestData))]
-        public static void CopyTo_Valid_Correct<T>(IReadOnlyList<T> source, IList<T> destination, int index, IList<T> expected)
+        public static void CopyTo_Valid_Correct(IReadOnlyList<int> source, IList<int> destination, int index, IList<int> expected)
         {
         {
             source.CopyTo(destination, index);
             source.CopyTo(destination, index);
             Assert.Equal(expected, destination);
             Assert.Equal(expected, destination);
@@ -29,29 +27,21 @@ namespace Jellyfin.Extensions.Tests
 
 
         public static TheoryData<IReadOnlyList<int>, IList<int>, int> CopyTo_Invalid_ThrowsArgumentOutOfRangeException_TestData()
         public static TheoryData<IReadOnlyList<int>, IList<int>, int> CopyTo_Invalid_ThrowsArgumentOutOfRangeException_TestData()
         {
         {
-            var data = new TheoryData<IReadOnlyList<int>, IList<int>, int>();
-
-            data.Add(
-                new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, -1 );
-
-            data.Add(
-                new[] { 0, 1, 2 }, new[] { 5, 4, 3, 2, 1, 0 }, 6 );
-
-            data.Add(
-                new[] { 0, 1, 2 }, Array.Empty<int>(), 0 );
-
-            data.Add(
-                new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0 }, 0 );
-
-            data.Add(
-                new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, 1 );
+            var data = new TheoryData<IReadOnlyList<int>, IList<int>, int>
+            {
+                { new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, -1 },
+                { new[] { 0, 1, 2 }, new[] { 5, 4, 3, 2, 1, 0 }, 6 },
+                { new[] { 0, 1, 2 }, Array.Empty<int>(), 0 },
+                { new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0 }, 0 },
+                { new[] { 0, 1, 2, 3, 4, 5 }, new[] { 0, 0, 0, 0, 0, 0 }, 1 }
+            };
 
 
             return data;
             return data;
         }
         }
 
 
         [Theory]
         [Theory]
         [MemberData(nameof(CopyTo_Invalid_ThrowsArgumentOutOfRangeException_TestData))]
         [MemberData(nameof(CopyTo_Invalid_ThrowsArgumentOutOfRangeException_TestData))]
-        public static void CopyTo_Invalid_ThrowsArgumentOutOfRangeException<T>(IReadOnlyList<T> source, IList<T> destination, int index)
+        public static void CopyTo_Invalid_ThrowsArgumentOutOfRangeException(IReadOnlyList<int> source, IList<int> destination, int index)
         {
         {
             Assert.Throws<ArgumentOutOfRangeException>(() => source.CopyTo(destination, index));
             Assert.Throws<ArgumentOutOfRangeException>(() => source.CopyTo(destination, index));
         }
         }

+ 1 - 1
tests/Jellyfin.Model.Tests/Entities/MediaStreamTests.cs

@@ -192,7 +192,7 @@ namespace Jellyfin.Model.Tests.Entities
         [InlineData(4090, 3070, false, "4K")]
         [InlineData(4090, 3070, false, "4K")]
         [InlineData(7680, 4320, false, "8K")]
         [InlineData(7680, 4320, false, "8K")]
         [InlineData(8190, 6140, false, "8K")]
         [InlineData(8190, 6140, false, "8K")]
-        public void GetResolutionText_Valid(int? width, int? height, bool interlaced, string expected)
+        public void GetResolutionText_Valid(int? width, int? height, bool interlaced, string? expected)
         {
         {
             var mediaStream = new MediaStream()
             var mediaStream = new MediaStream()
             {
             {

+ 1 - 2
tests/Jellyfin.Naming.Tests/Video/CleanDateTimeTests.cs

@@ -52,9 +52,8 @@ namespace Jellyfin.Naming.Tests.Video
         [InlineData("My Movie 2013-12-09", "My Movie 2013-12-09", null)]
         [InlineData("My Movie 2013-12-09", "My Movie 2013-12-09", null)]
         [InlineData("My Movie 20131209", "My Movie 20131209", null)]
         [InlineData("My Movie 20131209", "My Movie 20131209", null)]
         [InlineData("My Movie 2013-12-09 2013", "My Movie 2013-12-09", 2013)]
         [InlineData("My Movie 2013-12-09 2013", "My Movie 2013-12-09", 2013)]
-        [InlineData(null, null, null)]
         [InlineData("", "", null)]
         [InlineData("", "", null)]
-        public void CleanDateTimeTest(string input, string expectedName, int? expectedYear)
+        public void CleanDateTimeTest(string input, string? expectedName, int? expectedYear)
         {
         {
             input = Path.GetFileName(input);
             input = Path.GetFileName(input);
 
 

+ 0 - 1
tests/Jellyfin.Networking.Tests/Configuration/NetworkConfigurationTests.cs

@@ -6,7 +6,6 @@ namespace Jellyfin.Networking.Tests.Configuration;
 public static class NetworkConfigurationTests
 public static class NetworkConfigurationTests
 {
 {
     [Theory]
     [Theory]
-    [InlineData("", null)]
     [InlineData("", "")]
     [InlineData("", "")]
     [InlineData("/Test", "/Test")]
     [InlineData("/Test", "/Test")]
     [InlineData("/Test", "Test")]
     [InlineData("/Test", "Test")]

+ 2 - 2
tests/Jellyfin.Providers.Tests/MediaInfo/EmbeddedImageProviderTests.cs

@@ -55,7 +55,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
         [InlineData("clearlogo.png", null, 1, ImageType.Logo, ImageFormat.Png)] // extract extension from name
         [InlineData("clearlogo.png", null, 1, ImageType.Logo, ImageFormat.Png)] // extract extension from name
         [InlineData("backdrop", "image/bmp", 2, ImageType.Backdrop, ImageFormat.Bmp)] // extract extension from mimetype
         [InlineData("backdrop", "image/bmp", 2, ImageType.Backdrop, ImageFormat.Bmp)] // extract extension from mimetype
         [InlineData("poster", null, 3, ImageType.Primary, ImageFormat.Jpg)] // default extension to jpg
         [InlineData("poster", null, 3, ImageType.Primary, ImageFormat.Jpg)] // default extension to jpg
-        public async void GetImage_Attachment_ReturnsCorrectSelection(string filename, string mimetype, int targetIndex, ImageType type, ImageFormat? expectedFormat)
+        public async void GetImage_Attachment_ReturnsCorrectSelection(string filename, string? mimetype, int targetIndex, ImageType type, ImageFormat? expectedFormat)
         {
         {
             var attachments = new List<MediaAttachment>();
             var attachments = new List<MediaAttachment>();
             string pathPrefix = "path";
             string pathPrefix = "path";
@@ -103,7 +103,7 @@ namespace Jellyfin.Providers.Tests.MediaInfo
         [InlineData(null, "mjpeg", 1, ImageType.Primary, ImageFormat.Jpg)]
         [InlineData(null, "mjpeg", 1, ImageType.Primary, ImageFormat.Jpg)]
         [InlineData(null, "png", 1, ImageType.Primary, ImageFormat.Png)]
         [InlineData(null, "png", 1, ImageType.Primary, ImageFormat.Png)]
         [InlineData(null, "webp", 1, ImageType.Primary, ImageFormat.Webp)]
         [InlineData(null, "webp", 1, ImageType.Primary, ImageFormat.Webp)]
-        public async void GetImage_Embedded_ReturnsCorrectSelection(string label, string? codec, int targetIndex, ImageType type, ImageFormat? expectedFormat)
+        public async void GetImage_Embedded_ReturnsCorrectSelection(string? label, string? codec, int targetIndex, ImageType type, ImageFormat? expectedFormat)
         {
         {
             var streams = new List<MediaStream>();
             var streams = new List<MediaStream>();
             for (int i = 1; i <= targetIndex; i++)
             for (int i = 1; i <= targetIndex; i++)

+ 1 - 4
tests/Jellyfin.Providers.Tests/Tmdb/TmdbUtilsTests.cs

@@ -25,14 +25,11 @@ namespace Jellyfin.Providers.Tests.Tmdb
         }
         }
 
 
         [Theory]
         [Theory]
-        [InlineData(null, null, null)]
-        [InlineData(null, "en-US", null)]
-        [InlineData("en", null, "en")]
         [InlineData("en", "en-US", "en-US")]
         [InlineData("en", "en-US", "en-US")]
         [InlineData("fr-CA", "fr-BE", "fr-CA")]
         [InlineData("fr-CA", "fr-BE", "fr-CA")]
         [InlineData("fr-CA", "fr", "fr-CA")]
         [InlineData("fr-CA", "fr", "fr-CA")]
         [InlineData("de", "en-US", "de")]
         [InlineData("de", "en-US", "de")]
-        public static void AdjustImageLanguage_Valid_Success(string imageLanguage, string requestLanguage, string expected)
+        public static void AdjustImageLanguage_Valid_Success(string imageLanguage, string requestLanguage, string? expected)
         {
         {
             Assert.Equal(expected, TmdbUtils.AdjustImageLanguage(imageLanguage, requestLanguage));
             Assert.Equal(expected, TmdbUtils.AdjustImageLanguage(imageLanguage, requestLanguage));
         }
         }

+ 1 - 1
tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs

@@ -83,7 +83,7 @@ namespace Jellyfin.Server.Implementations.Tests.Library
         [InlineData(@"\home/jeff\myfile.mkv", '\\', @"\home\jeff\myfile.mkv")]
         [InlineData(@"\home/jeff\myfile.mkv", '\\', @"\home\jeff\myfile.mkv")]
         [InlineData(@"\home/jeff\myfile.mkv", '/', "/home/jeff/myfile.mkv")]
         [InlineData(@"\home/jeff\myfile.mkv", '/', "/home/jeff/myfile.mkv")]
         [InlineData("", '/', "")]
         [InlineData("", '/', "")]
-        public void NormalizePath_SpecifyingSeparator_Normalizes(string path, char separator, string expectedPath)
+        public void NormalizePath_SpecifyingSeparator_Normalizes(string? path, char separator, string? expectedPath)
         {
         {
             Assert.Equal(expectedPath, path.NormalizePath(separator));
             Assert.Equal(expectedPath, path.NormalizePath(separator));
         }
         }

+ 2 - 2
tests/Jellyfin.Server.Implementations.Tests/QuickConnect/QuickConnectManagerTests.cs

@@ -85,10 +85,10 @@ namespace Jellyfin.Server.Implementations.Tests.QuickConnect
         }
         }
 
 
         [Fact]
         [Fact]
-        public void AuthorizeRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
+        public async Task AuthorizeRequest_QuickConnectUnavailable_ThrowsAuthenticationException()
         {
         {
             _config.QuickConnectAvailable = false;
             _config.QuickConnectAvailable = false;
-            Assert.ThrowsAsync<AuthenticationException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, string.Empty));
+            await Assert.ThrowsAsync<AuthenticationException>(() => _quickConnectManager.AuthorizeRequest(Guid.Empty, string.Empty));
         }
         }
 
 
         [Fact]
         [Fact]

+ 1 - 1
tests/Jellyfin.Server.Implementations.Tests/SessionManager/SessionManagerTests.cs

@@ -21,7 +21,7 @@ public class SessionManagerTests
     [Theory]
     [Theory]
     [InlineData("", typeof(ArgumentException))]
     [InlineData("", typeof(ArgumentException))]
     [InlineData(null, typeof(ArgumentNullException))]
     [InlineData(null, typeof(ArgumentNullException))]
-    public async Task GetAuthorizationToken_Should_ThrowException(string deviceId, Type exceptionType)
+    public async Task GetAuthorizationToken_Should_ThrowException(string? deviceId, Type exceptionType)
     {
     {
         await using var sessionManager = new Emby.Server.Implementations.Session.SessionManager(
         await using var sessionManager = new Emby.Server.Implementations.Session.SessionManager(
             NullLogger<Emby.Server.Implementations.Session.SessionManager>.Instance,
             NullLogger<Emby.Server.Implementations.Session.SessionManager>.Instance,