jellyfin/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs

29 lines
1.1 KiB
C#
Raw Normal View History

2020-04-20 08:16:22 +00:00
using System;
2020-04-19 13:18:28 +00:00
using Emby.Server.Implementations.Library;
using Xunit;
namespace Jellyfin.Server.Implementations.Tests.Library
{
public class PathExtensionsTests
{
[Theory]
[InlineData("Superman: Red Son [imdbid=tt10985510]", "imdbid", "tt10985510")]
[InlineData("Superman: Red Son - tt10985510", "imdbid", "tt10985510")]
[InlineData("Superman: Red Son", "imdbid", null)]
2020-09-20 12:02:41 +00:00
[InlineData("Superman: Red Son", "something", null)]
2020-04-21 08:18:26 +00:00
public void GetAttributeValue_ValidArgs_Correct(string input, string attribute, string? expectedResult)
2020-04-19 13:18:28 +00:00
{
2020-04-21 08:18:26 +00:00
Assert.Equal(expectedResult, PathExtensions.GetAttributeValue(input, attribute));
2020-04-19 13:18:28 +00:00
}
2020-04-20 08:16:22 +00:00
[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));
}
2020-04-19 13:18:28 +00:00
}
}