SimpleEpisodeTests.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.IO;
  2. using Emby.Naming.Common;
  3. using Emby.Naming.TV;
  4. using Xunit;
  5. namespace Jellyfin.Naming.Tests.TV
  6. {
  7. public class SimpleEpisodeTests
  8. {
  9. private readonly EpisodeResolver _resolver = new EpisodeResolver(new NamingOptions());
  10. [Theory]
  11. [InlineData("/server/anything_s01e02.mp4", "anything", 1, 2)]
  12. [InlineData("/server/anything_s1e2.mp4", "anything", 1, 2)]
  13. [InlineData("/server/anything_s01.e02.mp4", "anything", 1, 2)]
  14. [InlineData("/server/anything_102.mp4", "anything", 1, 2)]
  15. [InlineData("/server/anything_1x02.mp4", "anything", 1, 2)]
  16. [InlineData("/server/The Walking Dead 4x01.mp4", "The Walking Dead", 4, 1)]
  17. [InlineData("/server/the_simpsons-s02e01_18536.mp4", "the_simpsons", 2, 1)]
  18. [InlineData("/server/Temp/S01E02 foo.mp4", "", 1, 2)]
  19. [InlineData("Series/4x12 - The Woman.mp4", "", 4, 12)]
  20. [InlineData("Series/LA X, Pt. 1_s06e32.mp4", "LA X, Pt. 1", 6, 32)]
  21. [InlineData("[Baz-Bar]Foo - [1080p][Multiple Subtitle]/[Baz-Bar] Foo - 05 [1080p][Multiple Subtitle].mkv", "Foo", null, 5)]
  22. [InlineData("/Foo/The.Series.Name.S01E04.WEBRip.x264-Baz[Bar]/the.series.name.s01e04.webrip.x264-Baz[Bar].mkv", "The.Series.Name", 1, 4)]
  23. [InlineData("Love.Death.and.Robots.S01.1080p.NF.WEB-DL.DDP5.1.x264-NTG/Love.Death.and.Robots.S01E01.Sonnies.Edge.1080p.NF.WEB-DL.DDP5.1.x264-NTG.mkv", "Love.Death.and.Robots", 1, 1)]
  24. [InlineData("[YuiSubs] Tensura Nikki - Tensei Shitara Slime Datta Ken/[YuiSubs] Tensura Nikki - Tensei Shitara Slime Datta Ken - 12 (NVENC H.265 1080p).mkv", "Tensura Nikki - Tensei Shitara Slime Datta Ken", null, 12)]
  25. [InlineData("[Baz-Bar]Foo - 01 - 12[1080p][Multiple Subtitle]/[Baz-Bar] Foo - 05 [1080p][Multiple Subtitle].mkv", "Foo", null, 5)]
  26. [InlineData("Series/4-12 - The Woman.mp4", "", 4, 12, 12)]
  27. // TODO: [InlineData("E:\\Anime\\Yahari Ore no Seishun Love Comedy wa Machigatteiru\\Yahari Ore no Seishun Love Comedy wa Machigatteiru. Zoku\\Oregairu Zoku 11 - Hayama Hayato Always Renconds to Everyone's Expectations..mkv", "Yahari Ore no Seishun Love Comedy wa Machigatteiru", null, 11)]
  28. // TODO: [InlineData(@"/Library/Series/The Grand Tour (2016)/Season 1/S01E01 The Holy Trinity.mkv", "The Grand Tour", 1, 1)]
  29. public void TestSimple(string path, string seriesName, int? seasonNumber, int? episodeNumber, int? episodeEndNumber = null)
  30. {
  31. var result = _resolver.Resolve(path, false);
  32. Assert.NotNull(result);
  33. Assert.Equal(seasonNumber, result!.SeasonNumber);
  34. Assert.Equal(episodeNumber, result!.EpisodeNumber);
  35. Assert.Equal(seriesName, result!.SeriesName, true);
  36. Assert.Equal(path, result!.Path);
  37. Assert.Equal(Path.GetExtension(path).Substring(1), result?.Container);
  38. Assert.Null(result!.Format3D);
  39. Assert.False(result!.Is3D);
  40. Assert.False(result!.IsStub);
  41. Assert.Null(result!.StubType);
  42. Assert.Equal(episodeEndNumber, result!.EndingEpisodeNumber);
  43. Assert.False(result!.IsByDate);
  44. }
  45. }
  46. }