mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 10:11:10 +00:00
Adds hidden elements option to file system browser directories and paths
This commit is contained in:
1 parent
15a1881495
commit
b3db46ed5f
18 files changed
+217
-59
No files matched your search
+32
@@ -124,6 +124,38 @@ public class PathServiceTests
|
||||
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == existingPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
_mockPathStrategy.Exists(pathId, true).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(existingPath, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == existingPath));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\ExistingPath";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
_mockPathStrategy.Exists(pathId, false).Returns(false);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(existingPath, false);
|
||||
|
||||
// Assert
|
||||
result.Should().BeFalse();
|
||||
_mockPathStrategy.Received(1).Exists(Arg.Is<FileSystemPathId>(id => id.Path == existingPath), false);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WithValidNonExistingPath_ShouldReturnFalse()
|
||||
{
|
||||
|
||||
+30
-6
@@ -128,18 +128,40 @@ public class UnixPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExists_ShouldReturnTrue()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
_mockFileSystem.Path.Received(1).Exists(existingPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = "/home/user/existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
IFileInfo mockFileInfo = Substitute.For<IFileInfo>();
|
||||
mockFileInfo.Attributes.Returns(System.IO.FileAttributes.Hidden);
|
||||
_mockFileSystem.FileInfo.New(Arg.Any<string>()).Returns(mockFileInfo);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, false);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
result.Should().BeFalse();
|
||||
_mockFileSystem.Path.Received(1).Exists(existingPath);
|
||||
}
|
||||
|
||||
@@ -168,7 +190,7 @@ public class UnixPathStrategyTests
|
||||
_mockFileSystem.Path.Exists(rootPath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
@@ -182,9 +204,10 @@ public class UnixPathStrategyTests
|
||||
string directoryPath = "/home/user/documents/";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(directoryPath);
|
||||
_mockFileSystem.Path.Exists(directoryPath).Returns(true);
|
||||
_mockFileSystem.Directory.Exists(directoryPath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
@@ -198,9 +221,10 @@ public class UnixPathStrategyTests
|
||||
string filePath = "/home/user/documents/file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(filePath);
|
||||
_mockFileSystem.Path.Exists(filePath).Returns(true);
|
||||
_mockFileSystem.File.Exists(filePath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
|
||||
+28
-5
@@ -156,21 +156,42 @@ public class WindowsPathStrategyTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExists_ShouldReturnTrue()
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsTrue_ShouldReturnTrue()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
_mockFileSystem.Path.Received(1).Exists(existingPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathExistsAndIsHiddenAndIncludeHiddenElementsIsFalse_ShouldReturnFalse()
|
||||
{
|
||||
// Arrange
|
||||
string existingPath = @"C:\Users\User\existing_file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(existingPath);
|
||||
_mockFileSystem.Path.Exists(existingPath).Returns(true);
|
||||
_mockFileSystem.File.Exists(existingPath).Returns(true);
|
||||
IFileInfo mockFileInfo = Substitute.For<IFileInfo>();
|
||||
mockFileInfo.Attributes.Returns(System.IO.FileAttributes.Hidden);
|
||||
_mockFileSystem.FileInfo.New(Arg.Any<string>()).Returns(mockFileInfo);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId, false);
|
||||
|
||||
// Assert
|
||||
result.Should().BeFalse();
|
||||
_mockFileSystem.Path.Received(1).Exists(existingPath);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Exists_WhenPathDoesNotExist_ShouldReturnFalse()
|
||||
{
|
||||
@@ -210,9 +231,10 @@ public class WindowsPathStrategyTests
|
||||
string directoryPath = @"C:\Users\User\Documents\";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(directoryPath);
|
||||
_mockFileSystem.Path.Exists(directoryPath).Returns(true);
|
||||
_mockFileSystem.Directory.Exists(directoryPath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
@@ -226,9 +248,10 @@ public class WindowsPathStrategyTests
|
||||
string filePath = @"C:\Users\User\Documents\file.txt";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(filePath);
|
||||
_mockFileSystem.Path.Exists(filePath).Returns(true);
|
||||
_mockFileSystem.File.Exists(filePath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
@@ -244,7 +267,7 @@ public class WindowsPathStrategyTests
|
||||
_mockFileSystem.Path.Exists(uncPath).Returns(true);
|
||||
|
||||
// Act
|
||||
bool result = _sut.Exists(pathId);
|
||||
bool result = _sut.Exists(pathId, true);
|
||||
|
||||
// Assert
|
||||
result.Should().BeTrue();
|
||||
|
||||
Reference in new issue
Block a user