Cover more branches

This commit is contained in:
Bond_009 2020-04-20 10:16:22 +02:00
parent 7f4a229cd2
commit 958681cdff
3 changed files with 18 additions and 6 deletions

View File

@ -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());
}

View File

@ -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));
}

View File

@ -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));
}
}
}