ManagedFileSystemTests.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using AutoFixture;
  3. using AutoFixture.AutoMoq;
  4. using Emby.Server.Implementations.IO;
  5. using MediaBrowser.Model.System;
  6. using Xunit;
  7. namespace Jellyfin.Server.Implementations.Tests.IO
  8. {
  9. public class ManagedFileSystemTests
  10. {
  11. private readonly IFixture _fixture;
  12. private readonly ManagedFileSystem _sut;
  13. public ManagedFileSystemTests()
  14. {
  15. _fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
  16. _sut = _fixture.Create<ManagedFileSystem>();
  17. }
  18. [Theory]
  19. [InlineData("/Volumes/Library/Sample/Music/Playlists/", "../Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Music/Beethoven/Misc/Moonlight Sonata.mp3")]
  20. [InlineData("/Volumes/Library/Sample/Music/Playlists/", "../../Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Beethoven/Misc/Moonlight Sonata.mp3")]
  21. [InlineData("/Volumes/Library/Sample/Music/Playlists/", "Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Music/Playlists/Beethoven/Misc/Moonlight Sonata.mp3")]
  22. public void MakeAbsolutePathCorrectlyHandlesRelativeFilePaths(
  23. string folderPath,
  24. string filePath,
  25. string expectedAbsolutePath)
  26. {
  27. var generatedPath = _sut.MakeAbsolutePath(folderPath, filePath);
  28. if (MediaBrowser.Common.System.OperatingSystem.Id == OperatingSystemId.Windows)
  29. {
  30. var expectedWindowsPath = expectedAbsolutePath.Replace('/', '\\');
  31. Assert.Equal(expectedWindowsPath, generatedPath.Split(':')[1]);
  32. }
  33. else
  34. {
  35. Assert.Equal(expectedAbsolutePath, generatedPath);
  36. }
  37. }
  38. }
  39. }