Selaa lähdekoodia

Cover more branches

Bond_009 5 vuotta sitten
vanhempi
sitoutus
958681cdff

+ 3 - 3
tests/Jellyfin.Common.Tests/Extensions/StringExtensionsTests.cs

@@ -9,7 +9,7 @@ namespace Jellyfin.Common.Tests.Extensions
         [Theory]
         [InlineData("Banana split", ' ', "Banana")]
         [InlineData("Banana split", 'q', "Banana split")]
-        public void LeftPartCharTest(string str, char needle, string result)
+        public void LeftPart_ValidArgsCharNeedle_Correct(string str, char needle, string result)
         {
             Assert.Equal(result, str.AsSpan().LeftPart(needle).ToString());
         }
@@ -17,7 +17,7 @@ namespace Jellyfin.Common.Tests.Extensions
         [Theory]
         [InlineData("Banana split", " ", "Banana")]
         [InlineData("Banana split test", " split", "Banana")]
-        public void LeftPartWithoutStringComparisonTest(string str, string needle, string result)
+        public void LeftPart_ValidArgsWithoutStringComparison_Correct(string str, string needle, string result)
         {
             Assert.Equal(result, str.AsSpan().LeftPart(needle).ToString());
         }
@@ -27,7 +27,7 @@ namespace Jellyfin.Common.Tests.Extensions
         [InlineData("Banana split test", " split", StringComparison.Ordinal, "Banana")]
         [InlineData("Banana split test", " Split", StringComparison.Ordinal, "Banana split test")]
         [InlineData("Banana split test", " Splït", StringComparison.InvariantCultureIgnoreCase, "Banana split test")]
-        public void LeftPartTest(string str, string needle, StringComparison stringComparison, string result)
+        public void LeftPart_ValidArgs_Correct(string str, string needle, StringComparison stringComparison, string result)
         {
             Assert.Equal(result, str.AsSpan().LeftPart(needle, stringComparison).ToString());
         }

+ 4 - 2
tests/Jellyfin.Server.Implementations.Tests/HttpServer/ResponseFilterTests.cs

@@ -3,12 +3,14 @@ using Xunit;
 
 namespace Jellyfin.Server.Implementations.Tests.HttpServer
 {
-    public class HttpServerTests
+    public class ResponseFilterTests
     {
         [Theory]
+        [InlineData(null, null)]
+        [InlineData("", "")]
         [InlineData("This is a clean string.", "This is a clean string.")]
         [InlineData("This isn't \n\ra clean string.", "This isn't a clean string.")]
-        public void RemoveControlCharactersTest(string input, string result)
+        public void RemoveControlCharacters_ValidArgs_Correct(string? input, string? result)
         {
             Assert.Equal(result, ResponseFilter.RemoveControlCharacters(input));
         }

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

@@ -1,3 +1,4 @@
+using System;
 using Emby.Server.Implementations.Library;
 using Xunit;
 
@@ -9,9 +10,18 @@ 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)]
-        public void GetAttributeValueTest(string input, string attribute, string? result)
+        public void GetAttributeValue_ValidArgs_Correct(string input, string attribute, string? result)
         {
             Assert.Equal(result, PathExtensions.GetAttributeValue(input, attribute));
         }
+
+        [Theory]
+        [InlineData("", "")]
+        [InlineData("Superman: Red Son [imdbid=tt10985510]", "")]
+        [InlineData("", "imdbid")]
+        public void GetAttributeValue_EmptyString_ThrowsArgumentException(string input, string attribute)
+        {
+            Assert.Throws<ArgumentException>(() => PathExtensions.GetAttributeValue(input, attribute));
+        }
     }
 }