PathExtensionsTests.cs 1.1 KB

12345678910111213141516171819202122232425262728
  1. using System;
  2. using Emby.Server.Implementations.Library;
  3. using Xunit;
  4. namespace Jellyfin.Server.Implementations.Tests.Library
  5. {
  6. public class PathExtensionsTests
  7. {
  8. [Theory]
  9. [InlineData("Superman: Red Son [imdbid=tt10985510]", "imdbid", "tt10985510")]
  10. [InlineData("Superman: Red Son - tt10985510", "imdbid", "tt10985510")]
  11. [InlineData("Superman: Red Son", "imdbid", null)]
  12. [InlineData("Superman: Red Son", "something", null)]
  13. public void GetAttributeValue_ValidArgs_Correct(string input, string attribute, string? expectedResult)
  14. {
  15. Assert.Equal(expectedResult, PathExtensions.GetAttributeValue(input, attribute));
  16. }
  17. [Theory]
  18. [InlineData("", "")]
  19. [InlineData("Superman: Red Son [imdbid=tt10985510]", "")]
  20. [InlineData("", "imdbid")]
  21. public void GetAttributeValue_EmptyString_ThrowsArgumentException(string input, string attribute)
  22. {
  23. Assert.Throws<ArgumentException>(() => PathExtensions.GetAttributeValue(input, attribute));
  24. }
  25. }
  26. }