Cover more branches
This commit is contained in:
parent
7f4a229cd2
commit
958681cdff
|
@ -9,7 +9,7 @@ namespace Jellyfin.Common.Tests.Extensions
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("Banana split", ' ', "Banana")]
|
[InlineData("Banana split", ' ', "Banana")]
|
||||||
[InlineData("Banana split", 'q', "Banana split")]
|
[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());
|
Assert.Equal(result, str.AsSpan().LeftPart(needle).ToString());
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace Jellyfin.Common.Tests.Extensions
|
||||||
[Theory]
|
[Theory]
|
||||||
[InlineData("Banana split", " ", "Banana")]
|
[InlineData("Banana split", " ", "Banana")]
|
||||||
[InlineData("Banana split test", " 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());
|
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")]
|
||||||
[InlineData("Banana split test", " Split", StringComparison.Ordinal, "Banana split test")]
|
[InlineData("Banana split test", " Split", StringComparison.Ordinal, "Banana split test")]
|
||||||
[InlineData("Banana split test", " Splït", StringComparison.InvariantCultureIgnoreCase, "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());
|
Assert.Equal(result, str.AsSpan().LeftPart(needle, stringComparison).ToString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,14 @@ using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Server.Implementations.Tests.HttpServer
|
namespace Jellyfin.Server.Implementations.Tests.HttpServer
|
||||||
{
|
{
|
||||||
public class HttpServerTests
|
public class ResponseFilterTests
|
||||||
{
|
{
|
||||||
[Theory]
|
[Theory]
|
||||||
|
[InlineData(null, null)]
|
||||||
|
[InlineData("", "")]
|
||||||
[InlineData("This is a clean string.", "This is a clean string.")]
|
[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.")]
|
[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));
|
Assert.Equal(result, ResponseFilter.RemoveControlCharacters(input));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using Emby.Server.Implementations.Library;
|
using Emby.Server.Implementations.Library;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
@ -9,9 +10,18 @@ namespace Jellyfin.Server.Implementations.Tests.Library
|
||||||
[InlineData("Superman: Red Son [imdbid=tt10985510]", "imdbid", "tt10985510")]
|
[InlineData("Superman: Red Son [imdbid=tt10985510]", "imdbid", "tt10985510")]
|
||||||
[InlineData("Superman: Red Son - tt10985510", "imdbid", "tt10985510")]
|
[InlineData("Superman: Red Son - tt10985510", "imdbid", "tt10985510")]
|
||||||
[InlineData("Superman: Red Son", "imdbid", null)]
|
[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));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user