mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 14:11:10 +00:00
Standardizes the remaining boolean names across the stack
This commit is contained in:
1 parent
3e0c3b624f
commit
39f4a04459
40 files changed
+1062
-448
No files matched your search
+2
-2
@@ -105,7 +105,7 @@ public class DirectoryProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSubdirectoryPaths_WhenIncludeHiddenElementsIsFalse_ShouldExcludeHiddenDirectories()
|
||||
public void GetSubdirectoryPaths_WhenShouldIncludeHiddenElementsIsFalse_ShouldExcludeHiddenDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
@@ -126,7 +126,7 @@ public class DirectoryProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetSubdirectoryPaths_WhenIncludeHiddenElementsIsTrue_ShouldIncludeHiddenDirectories()
|
||||
public void GetSubdirectoryPaths_WhenShouldIncludeHiddenElementsIsTrue_ShouldIncludeHiddenDirectories()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ public class FileProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilePaths_WhenIncludeHiddenElementsIsFalse_ShouldExcludeHiddenFiles()
|
||||
public void GetFilePaths_WhenShouldIncludeHiddenElementsIsFalse_ShouldExcludeHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
@@ -109,7 +109,7 @@ public class FileProviderServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void GetFilePaths_WhenIncludeHiddenElementsIsTrue_ShouldIncludeHiddenFiles()
|
||||
public void GetFilePaths_WhenShouldIncludeHiddenElementsIsTrue_ShouldIncludeHiddenFiles()
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.Create();
|
||||
|
||||
+48
-2
@@ -131,7 +131,7 @@ public class PathServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
public void Exists_WhenPathIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
@@ -147,7 +147,7 @@ public class PathServiceTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
public void Exists_WhenPathIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
@@ -771,4 +771,50 @@ public class PathServiceTests
|
||||
Assert.False(result.IsFailure);
|
||||
Assert.Equal(100, result.Value.Name.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void IsPathWithin_WhenBothPathsAreValid_ShouldCreatePathIdsAndDelegateToTheStrategy()
|
||||
{
|
||||
// Arrange
|
||||
string path = @"C:\Media\Books\book.epub";
|
||||
string parentPath = @"C:\Media\Books";
|
||||
_mockPathStrategy.IsPathWithin(Arg.Any<FileSystemPathId>(), Arg.Any<FileSystemPathId>()).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(path, parentPath);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
_mockPathStrategy.Received(1).IsPathWithin(
|
||||
Arg.Is<FileSystemPathId>(pathId => pathId.Path == path),
|
||||
Arg.Is<FileSystemPathId>(pathId => pathId.Path == parentPath));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void IsPathWithin_WhenPathIsNotValid_ShouldReturnFalseWithoutCallingTheStrategy(string? invalidPath)
|
||||
{
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(invalidPath!, @"C:\Media");
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
_mockPathStrategy.DidNotReceive().IsPathWithin(Arg.Any<FileSystemPathId>(), Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData("")]
|
||||
[InlineData(" ")]
|
||||
public void IsPathWithin_WhenParentPathIsNotValid_ShouldReturnFalseWithoutCallingTheStrategy(string? invalidParentPath)
|
||||
{
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(@"C:\Media\Books\book.epub", invalidParentPath!);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
_mockPathStrategy.DidNotReceive().IsPathWithin(Arg.Any<FileSystemPathId>(), Arg.Any<FileSystemPathId>());
|
||||
}
|
||||
}
|
||||
+40
-2
@@ -120,7 +120,7 @@ public class UnixPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
@@ -138,7 +138,7 @@ public class UnixPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
@@ -596,4 +596,42 @@ public class UnixPathStrategyTests
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/books", "/media/books/book.epub")] // direct child
|
||||
[InlineData("/media", "/media/books/book.epub")] // nested descendant
|
||||
[InlineData("/media/books/", "/media/books/book.epub")] // trailing separator on the parent
|
||||
[InlineData("/media/books", "/media/books/sub/../book.epub")] // relative segments that stay inside
|
||||
public void IsPathWithin_WithContainedPaths_ShouldReturnTrue(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("/media/books", "/media/book.epub")] // sibling directory
|
||||
[InlineData("/media/books", "/Media/Books/book.epub")] // Unix paths are case-sensitive
|
||||
[InlineData("/media/books", "/media/other/book.epub")] // sibling directory
|
||||
[InlineData("/media/books", "/media/books/../other/book.epub")] // relative segment that escapes the parent
|
||||
[InlineData("/media/books", "/etc/passwd")] // unrelated location
|
||||
[InlineData("/media", "/media")] // the parent itself is not inside itself
|
||||
public void IsPathWithin_WithPathsOutsideTheParent_ShouldReturnFalse(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
+42
-2
@@ -148,7 +148,7 @@ public class WindowsPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
@@ -165,7 +165,7 @@ public class WindowsPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndShouldIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
@@ -811,4 +811,44 @@ public class WindowsPathStrategyTests
|
||||
Assert.True(result.IsFailure);
|
||||
Assert.Equal(Errors.FileSystemManagement.InvalidPath, result.FirstError);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Books\book.epub")] // direct child
|
||||
[InlineData(@"C:\Media", @"C:\Media\Books\book.epub")] // nested descendant
|
||||
[InlineData(@"C:\Media\Books\", @"C:\Media\Books\book.epub")] // trailing separator on the parent
|
||||
[InlineData(@"C:\Media\Books", @"c:\media\books\book.epub")] // Windows paths are case-insensitive
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Books\Sub\..\book.epub")] // relative segments that stay inside
|
||||
public void IsPathWithin_WithContainedPaths_ShouldReturnTrue(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.True(result);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\book.epub")] // sibling directory
|
||||
[InlineData(@"C:\Media\Books", @"D:\Media\Books\book.epub")] // different drive
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\BookShelf\book.epub")] // a sibling whose name shares the prefix
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Other\book.epub")] // sibling directory
|
||||
[InlineData(@"C:\Media\Books", @"C:\Media\Books\..\Other\book.epub")] // relative segment that escapes the parent
|
||||
[InlineData(@"C:\Media\Books", @"C:\Windows\System32\config\SAM")] // unrelated location
|
||||
[InlineData(@"C:\Media", @"C:\Media")] // the parent itself is not inside itself
|
||||
public void IsPathWithin_WithPathsOutsideTheParent_ShouldReturnFalse(string parentPath, string path)
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId parentPathId = _fileSystemPathIdFixture.Create(parentPath);
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.Create(path);
|
||||
|
||||
// Act
|
||||
bool result = _sut.IsPathWithin(pathId, parentPathId);
|
||||
|
||||
// Assert
|
||||
Assert.False(result);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user