CleanDateTimeTests.cs 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. // FIXME: [InlineData("Drug War 2013.mp4", "Drug War", 2013)]
  41. [InlineData("My Movie (1997) - GreatestReleaseGroup 2019.mp4", "My Movie", 1997)]
  42. // FIXME: [InlineData("First Man 2018 1080p.mkv", "First Man", 2018)]
  43. [InlineData("First Man (2018) 1080p.mkv", "First Man", 2018)]
  44. // FIXME: [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. public void CleanDateTimeTest(string input, string expectedName, int? expectedYear)
  48. {
  49. input = Path.GetFileName(input);
  50. var result = new VideoResolver(_namingOptions).CleanDateTime(input);
  51. Assert.Equal(expectedName, result.Name, true);
  52. Assert.Equal(expectedYear, result.Year);
  53. }
  54. }
  55. }