jellyfin/tests/Jellyfin.Server.Implementations.Tests/IO/ManagedFileSystemTests.cs

44 lines
1.7 KiB
C#
Raw Normal View History

using System;
using AutoFixture;
using AutoFixture.AutoMoq;
using Emby.Server.Implementations.IO;
using MediaBrowser.Model.System;
using Xunit;
2020-01-09 23:03:57 +01:00
namespace Jellyfin.Server.Implementations.Tests.IO
{
public class ManagedFileSystemTests
{
private readonly IFixture _fixture;
private readonly ManagedFileSystem _sut;
public ManagedFileSystemTests()
{
_fixture = new Fixture().Customize(new AutoMoqCustomization { ConfigureMembers = true });
_sut = _fixture.Create<ManagedFileSystem>();
}
[Theory]
[InlineData("/Volumes/Library/Sample/Music/Playlists/", "../Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Music/Beethoven/Misc/Moonlight Sonata.mp3")]
[InlineData("/Volumes/Library/Sample/Music/Playlists/", "../../Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Beethoven/Misc/Moonlight Sonata.mp3")]
[InlineData("/Volumes/Library/Sample/Music/Playlists/", "Beethoven/Misc/Moonlight Sonata.mp3", "/Volumes/Library/Sample/Music/Playlists/Beethoven/Misc/Moonlight Sonata.mp3")]
public void MakeAbsolutePathCorrectlyHandlesRelativeFilePaths(
string folderPath,
string filePath,
string expectedAbsolutePath)
{
var generatedPath = _sut.MakeAbsolutePath(folderPath, filePath);
if (MediaBrowser.Common.System.OperatingSystem.Id == OperatingSystemId.Windows)
{
var expectedWindowsPath = expectedAbsolutePath.Replace('/', '\\').Split(':')[1];
2020-01-13 07:43:06 +01:00
Assert.Equal(expectedWindowsPath, generatedPath);
}
else
{
Assert.Equal(expectedAbsolutePath, generatedPath);
}
}
}
}