CleanDateTimeTests.cs 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using System.IO;
  2. using Emby.Naming.Common;
  3. using Emby.Naming.Video;
  4. using Xunit;
  5. namespace Jellyfin.Naming.Tests.Video
  6. {
  7. public sealed class CleanDateTimeTests
  8. {
  9. private readonly NamingOptions _namingOptions = new NamingOptions();
  10. [Theory]
  11. [InlineData(@"The Wolf of Wall Street (2013).mkv", "The Wolf of Wall Street", 2013)]
  12. [InlineData(@"The Wolf of Wall Street 2 (2013).mkv", "The Wolf of Wall Street 2", 2013)]
  13. [InlineData(@"The Wolf of Wall Street - 2 (2013).mkv", "The Wolf of Wall Street - 2", 2013)]
  14. [InlineData(@"The Wolf of Wall Street 2001 (2013).mkv", "The Wolf of Wall Street 2001", 2013)]
  15. [InlineData(@"300 (2006).mkv", "300", 2006)]
  16. [InlineData(@"d:/movies/300 (2006).mkv", "300", 2006)]
  17. [InlineData(@"300 2 (2006).mkv", "300 2", 2006)]
  18. [InlineData(@"300 - 2 (2006).mkv", "300 - 2", 2006)]
  19. [InlineData(@"300 2001 (2006).mkv", "300 2001", 2006)]
  20. [InlineData(@"curse.of.chucky.2013.stv.unrated.multi.1080p.bluray.x264-rough", "curse.of.chucky", 2013)]
  21. [InlineData(@"curse.of.chucky.2013.stv.unrated.multi.2160p.bluray.x264-rough", "curse.of.chucky", 2013)]
  22. [InlineData(@"/server/Movies/300 (2007)/300 (2006).bluray.disc", "300", 2006)]
  23. [InlineData(@"Arrival.2016.2160p.Blu-Ray.HEVC.mkv", "Arrival", 2016)]
  24. [InlineData(@"The Wolf of Wall Street (2013)", "The Wolf of Wall Street", 2013)]
  25. [InlineData(@"The Wolf of Wall Street 2 (2013)", "The Wolf of Wall Street 2", 2013)]
  26. [InlineData(@"The Wolf of Wall Street - 2 (2013)", "The Wolf of Wall Street - 2", 2013)]
  27. [InlineData(@"The Wolf of Wall Street 2001 (2013)", "The Wolf of Wall Street 2001", 2013)]
  28. [InlineData(@"300 (2006)", "300", 2006)]
  29. [InlineData(@"d:/movies/300 (2006)", "300", 2006)]
  30. [InlineData(@"300 2 (2006)", "300 2", 2006)]
  31. [InlineData(@"300 - 2 (2006)", "300 - 2", 2006)]
  32. [InlineData(@"300 2001 (2006)", "300 2001", 2006)]
  33. [InlineData(@"/server/Movies/300 (2007)/300 (2006)", "300", 2006)]
  34. [InlineData(@"/server/Movies/300 (2007)/300 (2006).mkv", "300", 2006)]
  35. [InlineData(@"American.Psycho.mkv", "American.Psycho.mkv", null)]
  36. [InlineData(@"American Psycho.mkv", "American Psycho.mkv", null)]
  37. [InlineData(@"[rec].mkv", "[rec].mkv", null)]
  38. [InlineData(@"St. Vincent (2014)", "St. Vincent", 2014)]
  39. [InlineData("Super movie(2009).mp4", "Super movie", 2009)]
  40. [InlineData("Drug War 2013.mp4", "Drug War", 2013)]
  41. [InlineData("My Movie (1997) - GreatestReleaseGroup 2019.mp4", "My Movie", 1997)]
  42. [InlineData("First Man 2018 1080p.mkv", "First Man", 2018)]
  43. [InlineData("First Man (2018) 1080p.mkv", "First Man", 2018)]
  44. [InlineData("Maximum Ride - 2016 - WEBDL-1080p - x264 AC3.mkv", "Maximum Ride", 2016)]
  45. // FIXME: [InlineData("Robin Hood [Multi-Subs] [2018].mkv", "Robin Hood", 2018)]
  46. [InlineData(@"3.Days.to.Kill.2014.720p.BluRay.x264.YIFY.mkv", "3.Days.to.Kill", 2014)] // In this test case, running CleanDateTime first produces no date, so it will attempt to run CleanString first and then CleanDateTime again
  47. [InlineData("3 days to kill (2005).mkv", "3 days to kill", 2005)]
  48. [InlineData("My Movie 2013.12.09", "My Movie 2013.12.09", null)]
  49. [InlineData("My Movie 2013-12-09", "My Movie 2013-12-09", null)]
  50. [InlineData("My Movie 20131209", "My Movie 20131209", null)]
  51. [InlineData("My Movie 2013-12-09 2013", "My Movie 2013-12-09", 2013)]
  52. public void CleanDateTimeTest(string input, string expectedName, int? expectedYear)
  53. {
  54. input = Path.GetFileName(input);
  55. var result = new VideoResolver(_namingOptions).CleanDateTime(input);
  56. Assert.Equal(expectedName, result.Name, true);
  57. Assert.Equal(expectedYear, result.Year);
  58. }
  59. }
  60. }