mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-01 05:18:27 +01:00
Add some simple tests
This commit is contained in:
@@ -35,7 +35,8 @@ namespace Emby.Server.Implementations.Library
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int? GetDefaultSubtitleStreamIndex(List<MediaStream> streams,
|
||||
public static int? GetDefaultSubtitleStreamIndex(
|
||||
List<MediaStream> streams,
|
||||
string[] preferredLanguages,
|
||||
SubtitlePlaybackMode mode,
|
||||
string audioTrackLanguage)
|
||||
@@ -115,7 +116,8 @@ namespace Emby.Server.Implementations.Library
|
||||
.ThenBy(i => i.Index);
|
||||
}
|
||||
|
||||
public static void SetSubtitleStreamScores(List<MediaStream> streams,
|
||||
public static void SetSubtitleStreamScores(
|
||||
List<MediaStream> streams,
|
||||
string[] preferredLanguages,
|
||||
SubtitlePlaybackMode mode,
|
||||
string audioTrackLanguage)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@@ -12,24 +14,24 @@ namespace Emby.Server.Implementations.Library
|
||||
/// Gets the attribute value.
|
||||
/// </summary>
|
||||
/// <param name="str">The STR.</param>
|
||||
/// <param name="attrib">The attrib.</param>
|
||||
/// <param name="attribute">The attrib.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
/// <exception cref="ArgumentNullException">attrib</exception>
|
||||
public static string GetAttributeValue(this string str, string attrib)
|
||||
/// <exception cref="ArgumentException"><c>str</c> or <c>attribute</c> is empty.</exception>
|
||||
public static string? GetAttributeValue(this string str, string attribute)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
if (str.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(str));
|
||||
throw new ArgumentException("String can't be empty.", nameof(str));
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(attrib))
|
||||
if (attribute.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(attrib));
|
||||
throw new ArgumentException("String can't be empty.", nameof(attribute));
|
||||
}
|
||||
|
||||
string srch = "[" + attrib + "=";
|
||||
string srch = "[" + attribute + "=";
|
||||
int start = str.IndexOf(srch, StringComparison.OrdinalIgnoreCase);
|
||||
if (start > -1)
|
||||
if (start != -1)
|
||||
{
|
||||
start += srch.Length;
|
||||
int end = str.IndexOf(']', start);
|
||||
@@ -37,7 +39,7 @@ namespace Emby.Server.Implementations.Library
|
||||
}
|
||||
|
||||
// for imdbid we also accept pattern matching
|
||||
if (string.Equals(attrib, "imdbid", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(attribute, "imdbid", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var m = Regex.Match(str, "tt([0-9]{7,8})", RegexOptions.IgnoreCase);
|
||||
return m.Success ? m.Value : null;
|
||||
|
||||
@@ -118,10 +118,12 @@ namespace Emby.Server.Implementations.Library
|
||||
{
|
||||
throw new ArgumentNullException(nameof(fileSystem));
|
||||
}
|
||||
|
||||
if (item == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(item));
|
||||
}
|
||||
|
||||
if (args == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(args));
|
||||
|
||||
Reference in New Issue
Block a user