ExtraTests.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using Emby.Naming.Common;
  2. using Emby.Naming.Video;
  3. using MediaBrowser.Model.Entities;
  4. using Xunit;
  5. namespace Jellyfin.Naming.Tests.Video
  6. {
  7. public class ExtraTests : BaseVideoTest
  8. {
  9. // Requirements
  10. // movie-deleted = ExtraType deletedscene
  11. // All of the above rules should be configurable through the options objects (ideally, even the ExtraTypes)
  12. [Fact]
  13. public void TestKodiExtras()
  14. {
  15. var videoOptions = new NamingOptions();
  16. Test("trailer.mp4", ExtraType.Trailer, videoOptions);
  17. Test("300-trailer.mp4", ExtraType.Trailer, videoOptions);
  18. Test("theme.mp3", ExtraType.ThemeSong, videoOptions);
  19. }
  20. [Fact]
  21. public void TestExpandedExtras()
  22. {
  23. var videoOptions = new NamingOptions();
  24. Test("trailer.mp4", ExtraType.Trailer, videoOptions);
  25. Test("trailer.mp3", null, videoOptions);
  26. Test("300-trailer.mp4", ExtraType.Trailer, videoOptions);
  27. Test("theme.mp3", ExtraType.ThemeSong, videoOptions);
  28. Test("theme.mkv", null, videoOptions);
  29. Test("300-scene.mp4", ExtraType.Scene, videoOptions);
  30. Test("300-scene2.mp4", ExtraType.Scene, videoOptions);
  31. Test("300-clip.mp4", ExtraType.Clip, videoOptions);
  32. Test("300-deleted.mp4", ExtraType.DeletedScene, videoOptions);
  33. Test("300-deletedscene.mp4", ExtraType.DeletedScene, videoOptions);
  34. Test("300-interview.mp4", ExtraType.Interview, videoOptions);
  35. Test("300-behindthescenes.mp4", ExtraType.BehindTheScenes, videoOptions);
  36. }
  37. [Fact]
  38. public void TestSample()
  39. {
  40. var videoOptions = new NamingOptions();
  41. Test("300-sample.mp4", ExtraType.Sample, videoOptions);
  42. }
  43. private void Test(string input, ExtraType? expectedType, NamingOptions videoOptions)
  44. {
  45. var parser = GetExtraTypeParser(videoOptions);
  46. var extraType = parser.GetExtraInfo(input).ExtraType;
  47. if (expectedType == null)
  48. {
  49. Assert.Null(extraType);
  50. }
  51. else
  52. {
  53. Assert.Equal(expectedType, extraType);
  54. }
  55. }
  56. private ExtraResolver GetExtraTypeParser(NamingOptions videoOptions)
  57. {
  58. return new ExtraResolver(videoOptions);
  59. }
  60. }
  61. }