diff options
| author | Bond-009 <bond.009@outlook.com> | 2021-03-06 21:38:32 +0100 |
|---|---|---|
| committer | Joshua M. Boniface <joshua@boniface.me> | 2021-03-08 18:08:25 -0500 |
| commit | 42d0c1ac5fe56a5c0185197200d1efa63d6f78b9 (patch) | |
| tree | 8f7aaed76e747e0bba0274d7b67329a85fdabf41 /tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs | |
| parent | b01290013e438cef09866ff29c27f65680c0bead (diff) | |
Merge pull request #5381 from cvium/fix-network-substitution
(cherry picked from commit 497ea57fd295baa0a46c5ce6b25f109e1d6aeb3b)
Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
Diffstat (limited to 'tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs')
| -rw-r--r-- | tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs index 6d768af89..a6fe90566 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs @@ -24,5 +24,31 @@ namespace Jellyfin.Server.Implementations.Tests.Library { Assert.Throws<ArgumentException>(() => PathExtensions.GetAttributeValue(input, attribute)); } + + [Theory] + [InlineData("C:/Users/jeff/myfile.mkv", "C:/Users/jeff", "/home/jeff", "/home/jeff/myfile.mkv")] + [InlineData("C:/Users/jeff/myfile.mkv", "C:/Users/jeff/", "/home/jeff", "/home/jeff/myfile.mkv")] + [InlineData("/home/jeff/music/jeff's band/consistently inconsistent.mp3", "/home/jeff/music/jeff's band", "/home/not jeff", "/home/not jeff/consistently inconsistent.mp3")] + [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff", "/home/jeff", "/home/jeff/myfile.mkv")] + [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff", "/home/jeff/", "/home/jeff/myfile.mkv")] + [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff/", "/home/jeff/", "/home/jeff/myfile.mkv")] + [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff/", "/", "/myfile.mkv")] + public void TryReplaceSubPath_ValidArgs_Correct(string path, string subPath, string newSubPath, string? expectedResult) + { + Assert.True(PathExtensions.TryReplaceSubPath(path, subPath, newSubPath, out var result)); + Assert.Equal(expectedResult, result); + } + + [Theory] + [InlineData("", "", "")] + [InlineData("/my/path", "", "")] + [InlineData("", "/another/path", "")] + [InlineData("", "", "/new/subpath")] + [InlineData("/home/jeff/music/jeff's band/consistently inconsistent.mp3", "/home/jeff/music/not jeff's band", "/home/not jeff")] + public void TryReplaceSubPath_InvalidInput_ReturnsFalseAndNull(string path, string subPath, string newSubPath) + { + Assert.False(PathExtensions.TryReplaceSubPath(path, subPath, newSubPath, out var result)); + Assert.Null(result); + } } } |
