ManagedFileSystemTests.cs 1.7 KB

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