2
0

AudioBookListResolverTests.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. using System.Linq;
  2. using Emby.Naming.AudioBook;
  3. using Emby.Naming.Common;
  4. using MediaBrowser.Model.IO;
  5. using Xunit;
  6. namespace Jellyfin.Naming.Tests.AudioBook
  7. {
  8. public class AudioBookListResolverTests
  9. {
  10. private readonly NamingOptions _namingOptions = new NamingOptions();
  11. [Fact]
  12. public void TestStackAndExtras()
  13. {
  14. // No stacking here because there is no part/disc/etc
  15. var files = new[]
  16. {
  17. "Harry Potter and the Deathly Hallows/Part 1.mp3",
  18. "Harry Potter and the Deathly Hallows/Part 2.mp3",
  19. "Harry Potter and the Deathly Hallows/book.nfo",
  20. "Batman/Chapter 1.mp3",
  21. "Batman/Chapter 2.mp3",
  22. "Batman/Chapter 3.mp3",
  23. };
  24. var resolver = GetResolver();
  25. var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
  26. {
  27. IsDirectory = false,
  28. FullName = i
  29. })).ToList();
  30. Assert.Equal(2, result[0].Files.Count);
  31. // Assert.Empty(result[0].Extras); FIXME: AudioBookListResolver should resolve extra files properly
  32. Assert.Equal("Harry Potter and the Deathly Hallows", result[0].Name);
  33. Assert.Equal(3, result[1].Files.Count);
  34. Assert.Empty(result[1].Extras);
  35. Assert.Equal("Batman", result[1].Name);
  36. }
  37. [Fact]
  38. public void TestWithMetadata()
  39. {
  40. var files = new[]
  41. {
  42. "Harry Potter and the Deathly Hallows/Chapter 1.ogg",
  43. "Harry Potter and the Deathly Hallows/Harry Potter and the Deathly Hallows.nfo"
  44. };
  45. var resolver = GetResolver();
  46. var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
  47. {
  48. IsDirectory = false,
  49. FullName = i
  50. }));
  51. Assert.Single(result);
  52. }
  53. [Fact]
  54. public void TestWithExtra()
  55. {
  56. var files = new[]
  57. {
  58. "Harry Potter and the Deathly Hallows/Chapter 1.mp3",
  59. "Harry Potter and the Deathly Hallows/Harry Potter and the Deathly Hallows trailer.mp3"
  60. };
  61. var resolver = GetResolver();
  62. var result = resolver.Resolve(files.Select(i => new FileSystemMetadata
  63. {
  64. IsDirectory = false,
  65. FullName = i
  66. })).ToList();
  67. Assert.Single(result);
  68. }
  69. private AudioBookListResolver GetResolver()
  70. {
  71. return new AudioBookListResolver(_namingOptions);
  72. }
  73. }
  74. }