|
|
@@ -3,75 +3,75 @@ public class PathUtilsTests {
|
|
|
|
|
|
#region 路径处理
|
|
|
|
|
|
- [Theory]
|
|
|
- [InlineData(@"\\?\C:\foo\bar.txt", @"\\?\C:\foo")]
|
|
|
- [InlineData(@"C:\foo\bar.txt", @"C:\foo")]
|
|
|
- [InlineData(@"\\?\C:\foo\bar", @"\\?\C:\foo")]
|
|
|
- [InlineData(@"C:\foo\bar", @"C:\foo")]
|
|
|
- [InlineData(@"C:\foo\bar\", @"C:\foo")]
|
|
|
- [InlineData(@"\\?\C:\foo\", @"\\?\C:")]
|
|
|
- [InlineData(@"C:\foo", @"C:")]
|
|
|
- [InlineData(@"C:\foo\", @"C:")]
|
|
|
- [InlineData("https://foo.bar/file/long/pack.zip?arg=1", "https://foo.bar/file/long")]
|
|
|
- [InlineData("https://foo.bar/file/", "https://foo.bar")]
|
|
|
- [InlineData("https://foo.bar/file/?arg=1", "https://foo.bar")]
|
|
|
- [InlineData("https://foo.bar/file?arg=1", "https://foo.bar")]
|
|
|
- public void 路径处理_RemoveLastPart(string input, string expected)
|
|
|
- => Assert.Equal(expected, PathUtils.RemoveLastPart(input));
|
|
|
+ [Test]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar.txt", @"\\?\C:\foo")]
|
|
|
+ [Arguments(@"C:\foo\bar.txt", @"C:\foo")]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar", @"\\?\C:\foo")]
|
|
|
+ [Arguments(@"C:\foo\bar", @"C:\foo")]
|
|
|
+ [Arguments(@"C:\foo\bar\", @"C:\foo")]
|
|
|
+ [Arguments(@"\\?\C:\foo\", @"\\?\C:")]
|
|
|
+ [Arguments(@"C:\foo", @"C:")]
|
|
|
+ [Arguments(@"C:\foo\", @"C:")]
|
|
|
+ [Arguments("https://foo.bar/file/long/pack.zip?arg=1", "https://foo.bar/file/long")]
|
|
|
+ [Arguments("https://foo.bar/file/", "https://foo.bar")]
|
|
|
+ [Arguments("https://foo.bar/file/?arg=1", "https://foo.bar")]
|
|
|
+ [Arguments("https://foo.bar/file?arg=1", "https://foo.bar")]
|
|
|
+ public async Task 路径处理_RemoveLastPart(string input, string expected)
|
|
|
+ => await Assert.That(PathUtils.RemoveLastPart(input)).IsEqualTo(expected);
|
|
|
|
|
|
- [Theory]
|
|
|
- [InlineData(@"\\?\C:\foo\bar.txt", "bar.txt")]
|
|
|
- [InlineData(@"C:\foo\bar.txt", "bar.txt")]
|
|
|
- [InlineData(@"\\?\C:\foo\bar", "bar")]
|
|
|
- [InlineData(@"C:\foo\bar", "bar")]
|
|
|
- [InlineData(@"C:\foo\bar\", "bar")]
|
|
|
- [InlineData(@"\\?\C:\foo\", "foo")]
|
|
|
- [InlineData(@"C:\foo", "foo")]
|
|
|
- [InlineData(@"C:\foo\", "foo")]
|
|
|
- [InlineData("https://foo.bar/file/long/pack.zip?arg=1", "pack.zip")]
|
|
|
- [InlineData("https://foo.bar/file/", "file")]
|
|
|
- [InlineData("https://foo.bar/file/?arg=1", "file")]
|
|
|
- [InlineData("https://foo.bar/file?arg=1", "file")]
|
|
|
- public void 路径处理_GetLastPart(string input, string expected)
|
|
|
- => Assert.Equal(expected, PathUtils.GetLastPart(input));
|
|
|
+ [Test]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar.txt", "bar.txt")]
|
|
|
+ [Arguments(@"C:\foo\bar.txt", "bar.txt")]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar", "bar")]
|
|
|
+ [Arguments(@"C:\foo\bar", "bar")]
|
|
|
+ [Arguments(@"C:\foo\bar\", "bar")]
|
|
|
+ [Arguments(@"\\?\C:\foo\", "foo")]
|
|
|
+ [Arguments(@"C:\foo", "foo")]
|
|
|
+ [Arguments(@"C:\foo\", "foo")]
|
|
|
+ [Arguments("https://foo.bar/file/long/pack.zip?arg=1", "pack.zip")]
|
|
|
+ [Arguments("https://foo.bar/file/", "file")]
|
|
|
+ [Arguments("https://foo.bar/file/?arg=1", "file")]
|
|
|
+ [Arguments("https://foo.bar/file?arg=1", "file")]
|
|
|
+ public async Task 路径处理_GetLastPart(string input, string expected)
|
|
|
+ => await Assert.That(PathUtils.GetLastPart(input)).IsEqualTo(expected);
|
|
|
|
|
|
- [Theory]
|
|
|
- [InlineData(@"\\?\C:\foo\bar.txt", "bar")]
|
|
|
- [InlineData(@"C:\foo\bar.2.txt", "bar.2")]
|
|
|
- [InlineData(@"\\?\C:\foo\bar", "bar")]
|
|
|
- [InlineData(@"C:\foo\bar", "bar")]
|
|
|
- [InlineData(@"C:\foo.bar\how\", "how")]
|
|
|
- [InlineData(@"\\?\C:\foo\", "foo")]
|
|
|
- [InlineData(@"C:\foo", "foo")]
|
|
|
- [InlineData(@"C:\foo\", "foo")]
|
|
|
- [InlineData("create.jar.disabled", "create.jar")]
|
|
|
- [InlineData("create.jar", "create")]
|
|
|
- [InlineData("create", "create")]
|
|
|
- [InlineData("https://foo.bar/file/page.xaml.vb?arg=1", "page.xaml")]
|
|
|
- [InlineData("https://foo.bar/file/long/pack.zip?arg=1", "pack")]
|
|
|
- [InlineData("https://foo.bar/some.how/file/", "file")]
|
|
|
- [InlineData("https://foo.bar/file/?arg=1", "file")]
|
|
|
- [InlineData("https://foo.bar/file?arg=1", "file")]
|
|
|
- public void 路径处理_GetFileNameWithoutExtension(string input, string expected)
|
|
|
- => Assert.Equal(expected, PathUtils.GetFileNameWithoutExtension(input));
|
|
|
+ [Test]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar.txt", "bar")]
|
|
|
+ [Arguments(@"C:\foo\bar.2.txt", "bar.2")]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar", "bar")]
|
|
|
+ [Arguments(@"C:\foo\bar", "bar")]
|
|
|
+ [Arguments(@"C:\foo.bar\how\", "how")]
|
|
|
+ [Arguments(@"\\?\C:\foo\", "foo")]
|
|
|
+ [Arguments(@"C:\foo", "foo")]
|
|
|
+ [Arguments(@"C:\foo\", "foo")]
|
|
|
+ [Arguments("create.jar.disabled", "create.jar")]
|
|
|
+ [Arguments("create.jar", "create")]
|
|
|
+ [Arguments("create", "create")]
|
|
|
+ [Arguments("https://foo.bar/file/page.xaml.vb?arg=1", "page.xaml")]
|
|
|
+ [Arguments("https://foo.bar/file/long/pack.zip?arg=1", "pack")]
|
|
|
+ [Arguments("https://foo.bar/some.how/file/", "file")]
|
|
|
+ [Arguments("https://foo.bar/file/?arg=1", "file")]
|
|
|
+ [Arguments("https://foo.bar/file?arg=1", "file")]
|
|
|
+ public async Task 路径处理_GetFileNameWithoutExtension(string input, string expected)
|
|
|
+ => await Assert.That(PathUtils.GetFileNameWithoutExtension(input)).IsEqualTo(expected);
|
|
|
|
|
|
- [Theory]
|
|
|
- [InlineData(@"\\?\C:\FOO\BAR.TXT", "txt")]
|
|
|
- [InlineData(@"C:\foo\bar.txt", "txt")]
|
|
|
- [InlineData(@"\\?\C:\foo\bar", "")]
|
|
|
- [InlineData(@"C:\foo\bar", "")]
|
|
|
- [InlineData(@"C:\foo\bar\", "")]
|
|
|
- [InlineData(@"\\?\C:\foo\", "")]
|
|
|
- [InlineData(@"C:\foo", "")]
|
|
|
- [InlineData(@"C:\foo\", "")]
|
|
|
- [InlineData("create.jar.diSAbled", "disabled")]
|
|
|
- [InlineData("https://foo.bar/file/page.xaml.vb?arg=1", "vb")]
|
|
|
- [InlineData("https://foo.bar/file/long/pack.ZIP?arg=1", "zip")]
|
|
|
- [InlineData("https://foo.bar/file/", "")]
|
|
|
- [InlineData("https://foo.bar/file/?arg=1", "")]
|
|
|
- [InlineData("https://foo.bar/file?arg=1", "")]
|
|
|
- public void 路径处理_GetExtension(string input, string expected)
|
|
|
- => Assert.Equal(expected, PathUtils.GetExtension(input));
|
|
|
+ [Test]
|
|
|
+ [Arguments(@"\\?\C:\FOO\BAR.TXT", "txt")]
|
|
|
+ [Arguments(@"C:\foo\bar.txt", "txt")]
|
|
|
+ [Arguments(@"\\?\C:\foo\bar", "")]
|
|
|
+ [Arguments(@"C:\foo\bar", "")]
|
|
|
+ [Arguments(@"C:\foo\bar\", "")]
|
|
|
+ [Arguments(@"\\?\C:\foo\", "")]
|
|
|
+ [Arguments(@"C:\foo", "")]
|
|
|
+ [Arguments(@"C:\foo\", "")]
|
|
|
+ [Arguments("create.jar.diSAbled", "disabled")]
|
|
|
+ [Arguments("https://foo.bar/file/page.xaml.vb?arg=1", "vb")]
|
|
|
+ [Arguments("https://foo.bar/file/long/pack.ZIP?arg=1", "zip")]
|
|
|
+ [Arguments("https://foo.bar/file/", "")]
|
|
|
+ [Arguments("https://foo.bar/file/?arg=1", "")]
|
|
|
+ [Arguments("https://foo.bar/file?arg=1", "")]
|
|
|
+ public async Task 路径处理_GetExtension(string input, string expected)
|
|
|
+ => await Assert.That(PathUtils.GetExtension(input)).IsEqualTo(expected);
|
|
|
|
|
|
#endregion
|
|
|
|