Skip to content

Commit

Permalink
Update FilePath tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rameel committed Aug 6, 2024
1 parent 39aa148 commit dbec8c7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Ramstack.FileProviders.Tests/FilePathTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,23 @@ public class FilePathTests
public string GetExtension(string path) =>
FilePath.GetExtension(path);

[TestCase("", ExpectedResult = "")]
[TestCase(".", ExpectedResult = ".")]
[TestCase(".hidden", ExpectedResult = ".hidden")]
[TestCase("file.txt", ExpectedResult = "file.txt")]
[TestCase("/path/to/file.txt", ExpectedResult = "file.txt")]
[TestCase("/path/to/.hidden", ExpectedResult = ".hidden")]
[TestCase("/path/to/file", ExpectedResult = "file")]
[TestCase("/path/with.dots/file.txt", ExpectedResult = "file.txt")]
[TestCase("/path/with.dots/file.", ExpectedResult = "file.")]
[TestCase("/path/to/file.with.multiple.dots.ext", ExpectedResult = "file.with.multiple.dots.ext")]
[TestCase("/path/to/.hidden.ext", ExpectedResult = ".hidden.ext")]
[TestCase("/.hidden", ExpectedResult = ".hidden")]
[TestCase("/path/to/", ExpectedResult = "")]
[TestCase("/path/to/directory/", ExpectedResult = "")]
public string GetFileNameTest(string path) =>
FilePath.GetFileName(path);

[TestCase("/", ExpectedResult = true)]
[TestCase("/a/b/c", ExpectedResult = true)]
[TestCase("/a/./b/c", ExpectedResult = true)]
Expand Down
2 changes: 1 addition & 1 deletion Ramstack.FileProviders/Internal/FilePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static string GetFileName(string path)
var start = p.LastIndexOf('/');
return start >= 0
? p.Slice(start + 1).ToString()
: "";
: path;
}

/// <summary>
Expand Down

0 comments on commit dbec8c7

Please sign in to comment.