diff options
| author | cvium <clausvium@gmail.com> | 2021-03-05 14:09:23 +0100 |
|---|---|---|
| committer | cvium <clausvium@gmail.com> | 2021-03-05 14:09:23 +0100 |
| commit | 37e374d33d73403470d07d814b5ee1367ca12e85 (patch) | |
| tree | 3c15de4310fed498e55c16e69643707f34bf2de3 /tests/Jellyfin.Server.Implementations.Tests/Library | |
| parent | 8615847a8aba1f504b184e79907e6885215ffdaa (diff) | |
make sure network path substitution matches correctly
Diffstat (limited to 'tests/Jellyfin.Server.Implementations.Tests/Library')
| -rw-r--r-- | tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs | 23 |
1 files changed, 23 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..a96a05377 100644 --- a/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs +++ b/tests/Jellyfin.Server.Implementations.Tests/Library/PathExtensionsTests.cs @@ -24,5 +24,28 @@ 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", true, "/home/jeff/myfile.mkv")] + [InlineData("C:/Users/jeff/myfile.mkv", "C:/Users/jeff/", "/home/jeff", true, "/home/jeff/myfile.mkv")] + [InlineData("/home/jeff/music/jeff's band/consistently inconsistent.mp3", "/home/jeff/music/not jeff's band", "/home/not jeff", false, null)] + [InlineData("/home/jeff/music/jeff's band/consistently inconsistent.mp3", "/home/jeff/music/jeff's band", "/home/not jeff", true, "/home/not jeff/consistently inconsistent.mp3")] + [InlineData("C:\\Users\\jeff\\myfile.mkv", "C:\\Users/jeff", "/home/jeff", true, "/home/jeff/myfile.mkv")] + public void TryReplaceSubPath_ValidArgs_Correct(string path, string subPath, string newSubPath, bool succeeded, string? expectedResult) + { + var status = PathExtensions.TryReplaceSubPath(path, subPath, newSubPath, out var result); + Assert.Equal(succeeded, status); + Assert.Equal(expectedResult, result); + } + + [Theory] + [InlineData("", "", "")] + [InlineData("/my/path", "", "")] + [InlineData("", "/another/path", "")] + [InlineData("", "", "/new/subpath")] + public void TryReplaceSubPath_EmptyString_ThrowsArgumentNullException(string path, string subPath, string newSubPath) + { + Assert.Throws<ArgumentNullException>(() => PathExtensions.TryReplaceSubPath(path, subPath, newSubPath, out _)); + } } } |
