mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-02 04:01:10 +00:00
Merge branch 'master' of https://github.com/BinaryAlley/Lumina into feature/add-multiplatform-testing-on-github-actions
This commit is contained in:
commit
d32f124147
11 files changed
+142
-142
No files matched your search
+3
-3
@@ -32,7 +32,7 @@ public class GetDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDirectoriesEndpointTests"/> class.
|
||||
@@ -103,8 +103,8 @@ public class GetDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
|
||||
|
||||
DirectoryResponse firstDirectory = directories!.First();
|
||||
firstDirectory.Name.Should().Be((s_isLinux ? "." : string.Empty) + "NestedDirectory_2");
|
||||
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
|
||||
firstDirectory.Name.Should().Be((s_isUnix ? "." : string.Empty) + "NestedDirectory_2");
|
||||
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
|
||||
directories!.Count.Should().Be(1); // only directories
|
||||
}
|
||||
finally
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDirectoryTreeEndpointTests"/> class.
|
||||
@@ -69,7 +69,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
treeNodes!.Should().NotBeEmpty();
|
||||
|
||||
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
pathSegments = ["/", .. pathSegments];
|
||||
// recursively validate the tree structure
|
||||
void ValidateNode(FileSystemTreeNodeResponse node, int depth)
|
||||
@@ -140,7 +140,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
treeNodes!.Should().NotBeEmpty();
|
||||
|
||||
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
pathSegments = ["/", .. pathSegments];
|
||||
|
||||
// recursively validate the tree structure
|
||||
@@ -173,7 +173,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
else if (childNode.ItemType is FileSystemItemType.File)
|
||||
{
|
||||
childNode.Children.Should().BeEmpty(); // files should not have children
|
||||
childNode.Name.Should().BeOneOf((s_isLinux ? "." : string.Empty) + "TestFile_1.txt", "TestFile_2.txt");
|
||||
childNode.Name.Should().BeOneOf((s_isUnix ? "." : string.Empty) + "TestFile_1.txt", "TestFile_2.txt");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
treeNodes.Should().AllSatisfy(node => node.ItemType.Should().BeOneOf(FileSystemItemType.Directory, FileSystemItemType.Root));
|
||||
|
||||
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
pathSegments = ["/", .. pathSegments];
|
||||
|
||||
// recursively validate the tree structure
|
||||
@@ -278,7 +278,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
treeNodes.Should().AllSatisfy(node => node.ItemType.Should().BeOneOf(FileSystemItemType.Directory, FileSystemItemType.Root));
|
||||
|
||||
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
|
||||
pathSegments = ["/", .. pathSegments];
|
||||
|
||||
// recursively validate the tree structure
|
||||
|
||||
+3
-3
@@ -33,7 +33,7 @@ public class GetTreeDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeDirectoriesEndpointTests"/> class.
|
||||
@@ -144,8 +144,8 @@ public class GetTreeDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
|
||||
|
||||
FileSystemTreeNodeResponse firstNode = treeNodes!.First();
|
||||
firstNode.Name.Should().Be((s_isLinux ? "." : string.Empty) + "NestedDirectory_2");
|
||||
firstNode.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
|
||||
firstNode.Name.Should().Be((s_isUnix ? "." : string.Empty) + "NestedDirectory_2");
|
||||
firstNode.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
|
||||
firstNode.ItemType.Should().Be(FileSystemItemType.Directory);
|
||||
treeNodes.Should().AllSatisfy(n => n.ItemType.Should().Be(FileSystemItemType.Directory));
|
||||
treeNodes!.Count.Should().Be(1); // only directories
|
||||
|
||||
+3
-3
@@ -29,7 +29,7 @@ public class GetDrivesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetDrivesEndpointTests"/> class.
|
||||
@@ -57,8 +57,8 @@ public class GetDrivesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
drives.Should().NotBeEmpty();
|
||||
|
||||
FileSystemTreeNodeResponse firstDrive = drives!.First();
|
||||
firstDrive.Name.Should().Be(s_isLinux ? "/" : "C:\\");
|
||||
firstDrive.Path.Should().Be(s_isLinux ? "/" : "C:\\");
|
||||
firstDrive.Name.Should().Be(s_isUnix ? "/" : "C:\\");
|
||||
firstDrive.Path.Should().Be(s_isUnix ? "/" : "C:\\");
|
||||
firstDrive.ItemType.Should().Be(FileSystemItemType.Root);
|
||||
drives!.Count.Should().BeGreaterThanOrEqualTo(1);
|
||||
}
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ public class GetFilesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetFilesEndpointTests"/> class.
|
||||
@@ -139,8 +139,8 @@ public class GetFilesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
FileResponse firstDirectory = files!.First();
|
||||
firstDirectory.Name.Should().Be((s_isLinux ? "." : string.Empty) + "TestFile_1.txt");
|
||||
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "TestFile_1.txt"));
|
||||
firstDirectory.Name.Should().Be((s_isUnix ? "." : string.Empty) + "TestFile_1.txt");
|
||||
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"));
|
||||
FileResponse secondDirectory = files!.Last();
|
||||
secondDirectory.Name.Should().Be("TestFile_2.txt");
|
||||
secondDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, "TestFile_2.txt"));
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@ public class GetTreeFilesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetTreeFilesEndpointTests"/> class.
|
||||
@@ -140,8 +140,8 @@ public class GetTreeFilesEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
|
||||
|
||||
FileSystemTreeNodeResponse firstDirectory = files!.First();
|
||||
firstDirectory.Name.Should().Be((s_isLinux ? "." : string.Empty) + "TestFile_1.txt");
|
||||
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "TestFile_1.txt"));
|
||||
firstDirectory.Name.Should().Be((s_isUnix ? "." : string.Empty) + "TestFile_1.txt");
|
||||
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"));
|
||||
FileSystemTreeNodeResponse secondDirectory = files!.Last();
|
||||
secondDirectory.Name.Should().Be("TestFile_2.txt");
|
||||
secondDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, "TestFile_2.txt"));
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ public class GetPathParentEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
PropertyNameCaseInsensitive = true,
|
||||
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
|
||||
};
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetPathParentEndpointTests"/> class.
|
||||
@@ -63,7 +63,7 @@ public class GetPathParentEndpointTests : IClassFixture<LuminaApiFactory>
|
||||
string path = System.IO.Path.GetDirectoryName(testPath)!;
|
||||
while (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
string segment = s_isLinux && path == System.IO.Path.DirectorySeparatorChar.ToString() ? path : System.IO.Path.GetFileName(path);
|
||||
string segment = s_isUnix && path == System.IO.Path.DirectorySeparatorChar.ToString() ? path : System.IO.Path.GetFileName(path);
|
||||
if (string.IsNullOrEmpty(segment))
|
||||
{
|
||||
hierarchy.Add(System.IO.Path.GetPathRoot(path)!.TrimEnd(System.IO.Path.DirectorySeparatorChar));
|
||||
|
||||
+52
-52
@@ -33,29 +33,29 @@ public class DirectoryProviderServiceTests
|
||||
private readonly IFileSystemPermissionsService _mockFileSystemPermissionsService;
|
||||
private readonly DirectoryProviderService _sut;
|
||||
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private readonly string _pathSource = s_isLinux ? "/Source" : @"C:\Source";
|
||||
private readonly string _pathSourceSubDir = s_isLinux ? "/Source/SubDir" : @"C:\Source\SubDir";
|
||||
private readonly string _pathSourceSubDir1 = s_isLinux ? "/Source/SubDir1" : @"C:\Source\SubDir1";
|
||||
private readonly string _pathSourceSubDir2 = s_isLinux ? "/Source/SubDir2" : @"C:\Source\SubDir2";
|
||||
private readonly string _pathSourceFile1 = s_isLinux ? "/Source/file1.txt" : @"C:\Source\file1.txt";
|
||||
private readonly string _pathSourceFile2 = s_isLinux ? "/Source/file2.txt" : @"C:\Source\file2.txt";
|
||||
private readonly string _pathDestinationFile1 = s_isLinux ? "/Destination/file1.txt" : @"C:\Destination\file1.txt";
|
||||
private readonly string _pathDestinationFile2 = s_isLinux ? "/Destination/file2.txt" : @"C:\Destination\file2.txt";
|
||||
private readonly string _pathDestination = s_isLinux ? "/Destination" : @"C:\Destination";
|
||||
private readonly string _pathDestinationSubDir = s_isLinux ? "/Destination/SubDir" : @"C:\Destination\SubDir";
|
||||
private readonly string _pathDestinationSubDir1 = s_isLinux ? "/Destination/SubDir1" : @"C:\Destination\SubDir1";
|
||||
private readonly string _pathDestinationSubDir2 = s_isLinux ? "/Destination/SubDir2" : @"C:\Destination\SubDir2";
|
||||
private readonly string _pathDestinationFile = s_isLinux ? "/Destination/file.txt" : @"C:\Destination\file.txt";
|
||||
private readonly string _pathVisible1 = s_isLinux ? "/Visible" : @"C:\Visible";
|
||||
private readonly string _pathHidden1 = s_isLinux ? "/Hidden" : @"C:\Hidden";
|
||||
private readonly string _pathVisible2 = s_isLinux ? "/Visible/" : @"C:\Visible\";
|
||||
private readonly string _pathHidden2 = s_isLinux ? "/Hidden/" : @"C:\Hidden\";
|
||||
private readonly string _pathValid1 = s_isLinux ? "/Valid" : @"C:\Valid";
|
||||
private readonly string _pathInvalid1 = s_isLinux ? "/Invalid" : @"C:\Invalid";
|
||||
private readonly string _pathValid2 = s_isLinux ? "/Valid/" : @"C:\Valid\";
|
||||
private readonly string _pathInvalid2 = s_isLinux ? "/Invalid/" : @"C:\Invalid\";
|
||||
private readonly char _dirSeparator = s_isLinux ? '/' : '\\';
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
private readonly string _pathSource = s_isUnix ? "/Source" : @"C:\Source";
|
||||
private readonly string _pathSourceSubDir = s_isUnix ? "/Source/SubDir" : @"C:\Source\SubDir";
|
||||
private readonly string _pathSourceSubDir1 = s_isUnix ? "/Source/SubDir1" : @"C:\Source\SubDir1";
|
||||
private readonly string _pathSourceSubDir2 = s_isUnix ? "/Source/SubDir2" : @"C:\Source\SubDir2";
|
||||
private readonly string _pathSourceFile1 = s_isUnix ? "/Source/file1.txt" : @"C:\Source\file1.txt";
|
||||
private readonly string _pathSourceFile2 = s_isUnix ? "/Source/file2.txt" : @"C:\Source\file2.txt";
|
||||
private readonly string _pathDestinationFile1 = s_isUnix ? "/Destination/file1.txt" : @"C:\Destination\file1.txt";
|
||||
private readonly string _pathDestinationFile2 = s_isUnix ? "/Destination/file2.txt" : @"C:\Destination\file2.txt";
|
||||
private readonly string _pathDestination = s_isUnix ? "/Destination" : @"C:\Destination";
|
||||
private readonly string _pathDestinationSubDir = s_isUnix ? "/Destination/SubDir" : @"C:\Destination\SubDir";
|
||||
private readonly string _pathDestinationSubDir1 = s_isUnix ? "/Destination/SubDir1" : @"C:\Destination\SubDir1";
|
||||
private readonly string _pathDestinationSubDir2 = s_isUnix ? "/Destination/SubDir2" : @"C:\Destination\SubDir2";
|
||||
private readonly string _pathDestinationFile = s_isUnix ? "/Destination/file.txt" : @"C:\Destination\file.txt";
|
||||
private readonly string _pathVisible1 = s_isUnix ? "/Visible" : @"C:\Visible";
|
||||
private readonly string _pathHidden1 = s_isUnix ? "/Hidden" : @"C:\Hidden";
|
||||
private readonly string _pathVisible2 = s_isUnix ? "/Visible/" : @"C:\Visible\";
|
||||
private readonly string _pathHidden2 = s_isUnix ? "/Hidden/" : @"C:\Hidden\";
|
||||
private readonly string _pathValid1 = s_isUnix ? "/Valid" : @"C:\Valid";
|
||||
private readonly string _pathInvalid1 = s_isUnix ? "/Invalid" : @"C:\Invalid";
|
||||
private readonly string _pathValid2 = s_isUnix ? "/Valid/" : @"C:\Valid\";
|
||||
private readonly string _pathInvalid2 = s_isUnix ? "/Invalid/" : @"C:\Invalid\";
|
||||
private readonly char _dirSeparator = s_isUnix ? '/' : '\\';
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectoryProviderServiceTests"/> class.
|
||||
@@ -172,14 +172,14 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
string[] subdirectories = s_isLinux
|
||||
string[] subdirectories = s_isUnix
|
||||
? ["/C", "/A", "/B"]
|
||||
: [@"C:\C", @"C:\A", @"C:\B"];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory, false).Returns(true);
|
||||
_mockFileSystem.Directory.GetDirectories(path.Path).Returns(subdirectories);
|
||||
_mockFileSystem.Path.DirectorySeparatorChar.Returns(_dirSeparator);
|
||||
_mockFileSystem.File.GetAttributes(Arg.Any<string>()).Returns(FileAttributes.Directory);
|
||||
string[] expectedPaths = s_isLinux
|
||||
string[] expectedPaths = s_isUnix
|
||||
? ["/A/", "/B/", "/C/"]
|
||||
: [@"C:\A\", @"C:\B\", @"C:\C\"];
|
||||
|
||||
@@ -241,7 +241,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetFileName_WhenPathIsValid_ShouldReturnFileName()
|
||||
{
|
||||
// Arrange
|
||||
string fullPath = s_isLinux
|
||||
string fullPath = s_isUnix
|
||||
? "/folder/subfolder/file.txt"
|
||||
: @"C:\folder\subfolder\file.txt";
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(fullPath);
|
||||
@@ -259,7 +259,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetFileName_WhenPathEndsWithDirectorySeparator_ShouldReturnLastSegment()
|
||||
{
|
||||
// Arrange
|
||||
string fullPath = s_isLinux
|
||||
string fullPath = s_isUnix
|
||||
? "/folder/subfolder/"
|
||||
: @"C:\folder\subfolder\";
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(fullPath);
|
||||
@@ -278,7 +278,7 @@ public class DirectoryProviderServiceTests
|
||||
public void GetFileName_WhenPathIsRoot_ShouldReturnEmptyString()
|
||||
{
|
||||
// Arrange
|
||||
string fullPath = s_isLinux
|
||||
string fullPath = s_isUnix
|
||||
? "/C/"
|
||||
: @"/";
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(fullPath);
|
||||
@@ -365,7 +365,7 @@ public class DirectoryProviderServiceTests
|
||||
// Arrange
|
||||
FileSystemPathId parentPath = _fileSystemPathIdFixture.CreateFileSystemPathId(@"C:\Parent");
|
||||
string directoryName = "NewDirectory";
|
||||
string fullPath = s_isLinux
|
||||
string fullPath = s_isUnix
|
||||
? "/Parent/NewDirectory"
|
||||
: @"C:\Parent\NewDirectory";
|
||||
|
||||
@@ -491,7 +491,7 @@ public class DirectoryProviderServiceTests
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathSource);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
string expectedNewDirectoryPath = s_isLinux
|
||||
string expectedNewDirectoryPath = s_isUnix
|
||||
? "/Destination - Copy (1)"
|
||||
: @"C:\Destination - Copy (1)";
|
||||
bool overrideExisting = false;
|
||||
@@ -598,7 +598,7 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/NonExistentSource" : @"C:\NonExistentSource"
|
||||
s_isUnix ? "/NonExistentSource" : @"C:\NonExistentSource"
|
||||
);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
@@ -667,7 +667,7 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.File.Received(1).Move(_pathSourceFile1, _pathDestinationFile1);
|
||||
_mockFileSystem.Directory.Received(1).Move(
|
||||
_pathSourceSubDir,
|
||||
s_isLinux ? "/Destination/SubDir" : @"C:\Destination\SubDir"
|
||||
s_isUnix ? "/Destination/SubDir" : @"C:\Destination\SubDir"
|
||||
);
|
||||
_mockFileSystem.Directory.Received(1).Delete(sourcePath.Path);
|
||||
}
|
||||
@@ -806,20 +806,20 @@ public class DirectoryProviderServiceTests
|
||||
_mockFileSystem.Directory.Exists(destPath.Path).Returns(true);
|
||||
|
||||
_mockFileSystem.Directory.Exists(_pathSourceSubDir).Returns(true);
|
||||
_mockFileSystem.Directory.Exists(s_isLinux ? "/Destination/SubDir" : @"C:\Destination\SubDir").Returns(true);
|
||||
_mockFileSystem.Directory.Exists(s_isUnix ? "/Destination/SubDir" : @"C:\Destination\SubDir").Returns(true);
|
||||
|
||||
_mockFileSystem.Directory.GetFiles(sourcePath.Path).Returns([]);
|
||||
_mockFileSystem.Directory.GetDirectories(sourcePath.Path).Returns([_pathSourceSubDir]);
|
||||
|
||||
_mockFileSystem.Directory.GetFiles(_pathSourceSubDir).Returns(
|
||||
s_isLinux ? ["/Source/SubDir/file.txt"] : [@"C:\Source\SubDir\file.txt"]
|
||||
s_isUnix ? ["/Source/SubDir/file.txt"] : [@"C:\Source\SubDir\file.txt"]
|
||||
);
|
||||
_mockFileSystem.Directory.GetDirectories(_pathSourceSubDir).Returns([]);
|
||||
|
||||
_mockFileSystem.Path.GetFileName(_pathSourceSubDir).Returns("SubDir");
|
||||
_mockFileSystem.Path.GetFileName(s_isLinux ? "/Source/SubDir/file.txt" : @"C:\Source\SubDir\file.txt").Returns("file.txt");
|
||||
_mockFileSystem.Path.GetFileName(s_isUnix ? "/Source/SubDir/file.txt" : @"C:\Source\SubDir\file.txt").Returns("file.txt");
|
||||
|
||||
_mockFileSystem.File.Exists(s_isLinux ? "/Destination/SubDir/file.txt" : @"C:\Destination\SubDir\file.txt").Returns(false);
|
||||
_mockFileSystem.File.Exists(s_isUnix ? "/Destination/SubDir/file.txt" : @"C:\Destination\SubDir\file.txt").Returns(false);
|
||||
|
||||
_mockFileSystem.Path.Combine(Arg.Any<string>(), Arg.Any<string>())
|
||||
.Returns(callInfo => Path.Combine(callInfo.ArgAt<string>(0), callInfo.ArgAt<string>(1)));
|
||||
@@ -834,8 +834,8 @@ public class DirectoryProviderServiceTests
|
||||
result.IsError.Should().BeFalse();
|
||||
result.Value.Should().Be(destPath);
|
||||
_mockFileSystem.File.Received(1).Move(
|
||||
s_isLinux ? "/Source/SubDir/file.txt" : @"C:\Source\SubDir\file.txt",
|
||||
s_isLinux ? "/Destination/SubDir/file.txt" : @"C:\Destination\SubDir\file.txt"
|
||||
s_isUnix ? "/Source/SubDir/file.txt" : @"C:\Source\SubDir\file.txt",
|
||||
s_isUnix ? "/Destination/SubDir/file.txt" : @"C:\Destination\SubDir\file.txt"
|
||||
);
|
||||
_mockFileSystem.Directory.Received(1).Delete(_pathSourceSubDir);
|
||||
_mockFileSystem.Directory.DidNotReceive().Delete(sourcePath.Path);
|
||||
@@ -846,11 +846,11 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName" : @"C:\OldName"
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName" : @"C:\NewName";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName" : @"C:\NewName";
|
||||
|
||||
IDirectoryInfo parentDirectoryInfo = Substitute.For<IDirectoryInfo>();
|
||||
parentDirectoryInfo.FullName.Returns(parentPath);
|
||||
@@ -873,11 +873,11 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName" : @"C:\OldName"
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName" : @"C:\NewName";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName" : @"C:\NewName";
|
||||
|
||||
IDirectoryInfo parentDirectoryInfo = Substitute.For<IDirectoryInfo>();
|
||||
parentDirectoryInfo.FullName.Returns(parentPath);
|
||||
@@ -899,11 +899,11 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName" : @"C:\OldName"
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName" : @"C:\NewName";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName" : @"C:\NewName";
|
||||
|
||||
IDirectoryInfo parentDirectoryInfo = Substitute.For<IDirectoryInfo>();
|
||||
parentDirectoryInfo.FullName.Returns(parentPath);
|
||||
@@ -926,7 +926,7 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName" : @"C:\OldName"
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
|
||||
@@ -946,10 +946,10 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName" : @"C:\OldName"
|
||||
s_isUnix ? "/OldName" : @"C:\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
|
||||
IDirectoryInfo parentDirectoryInfo = Substitute.For<IDirectoryInfo>();
|
||||
parentDirectoryInfo.FullName.Returns(parentPath);
|
||||
@@ -970,7 +970,7 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/DirectoryToDelete" : @"C:\DirectoryToDelete"
|
||||
s_isUnix ? "/DirectoryToDelete" : @"C:\DirectoryToDelete"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete, false).Returns(true);
|
||||
IDirectoryInfo mockDirectoryInfo = Substitute.For<IDirectoryInfo>();
|
||||
@@ -990,7 +990,7 @@ public class DirectoryProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/DirectoryToDelete" : @"C:\DirectoryToDelete"
|
||||
s_isUnix ? "/DirectoryToDelete" : @"C:\DirectoryToDelete"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete, false).Returns(false);
|
||||
|
||||
|
||||
+23
-23
@@ -34,10 +34,10 @@ public class DirectoryServiceTests
|
||||
private readonly DirectoryService _sut;
|
||||
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
|
||||
private readonly DirectoryFixture _directoryFixture;
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private readonly string _pathDirTest = s_isLinux ? "/TestDir" : @"C:\TestDir";
|
||||
private readonly string _pathDirTestSubDir1 = s_isLinux ? "/TestDir/Sub1" : @"C:\TestDir\Sub1";
|
||||
private readonly string _pathDirTestSubDir2 = s_isLinux ? "/TestDir/Sub2" : @"C:\TestDir\Sub2";
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
private readonly string _pathDirTest = s_isUnix ? "/TestDir" : @"C:\TestDir";
|
||||
private readonly string _pathDirTestSubDir1 = s_isUnix ? "/TestDir/Sub1" : @"C:\TestDir\Sub1";
|
||||
private readonly string _pathDirTestSubDir2 = s_isUnix ? "/TestDir/Sub2" : @"C:\TestDir\Sub2";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DirectoryServiceTests"/> class.
|
||||
@@ -130,7 +130,7 @@ public class DirectoryServiceTests
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
@@ -211,7 +211,7 @@ public class DirectoryServiceTests
|
||||
Directory parentDirectory = _directoryFixture.CreateDirectory();
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(parentDirectory.Id, includeHiddenElements)
|
||||
@@ -292,7 +292,7 @@ public class DirectoryServiceTests
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDirTest);
|
||||
bool includeHiddenElements = false;
|
||||
FileSystemPathId subPath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
s_isUnix ? "/TestDir/InaccessibleSub" : @"C:\TestDir\InaccessibleSub"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.GetSubdirectoryPaths(pathId, includeHiddenElements)
|
||||
@@ -492,11 +492,11 @@ public class DirectoryServiceTests
|
||||
public void RenameDirectory_WithValidStringPath_ShouldReturnRenamedDirectory()
|
||||
{
|
||||
// Arrange
|
||||
string oldPath = s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName";
|
||||
string oldPath = s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName";
|
||||
string newName = "NewName";
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(oldPath);
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
@@ -537,11 +537,11 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
@@ -567,7 +567,7 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
|
||||
@@ -587,11 +587,11 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.RenameDirectory(oldPathId, newName)
|
||||
@@ -620,11 +620,11 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "ExistingDirectory";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/ExistingDirectory" : @"C:\TestDir\ExistingDirectory"
|
||||
s_isUnix ? "/TestDir/ExistingDirectory" : @"C:\TestDir\ExistingDirectory"
|
||||
);
|
||||
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
@@ -645,7 +645,7 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
|
||||
@@ -669,11 +669,11 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId oldPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
s_isUnix ? "/TestDir/OldName" : @"C:\TestDir\OldName"
|
||||
);
|
||||
string newName = "NewName";
|
||||
FileSystemPathId newPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
s_isUnix ? "/TestDir/NewName" : @"C:\TestDir\NewName"
|
||||
);
|
||||
_mockPlatformContext.PathStrategy.CombinePath(Arg.Any<FileSystemPathId>(), newName)
|
||||
.Returns(ErrorOrFactory.From(newPathId));
|
||||
@@ -696,7 +696,7 @@ public class DirectoryServiceTests
|
||||
public void DeleteDirectory_WithValidStringPath_ShouldReturnDeleted()
|
||||
{
|
||||
// Arrange
|
||||
string path = s_isLinux ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete";
|
||||
string path = s_isUnix ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete";
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(path);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DeleteDirectory(pathId)
|
||||
@@ -729,7 +729,7 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete"
|
||||
s_isUnix ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DeleteDirectory(pathId)
|
||||
@@ -748,7 +748,7 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete"
|
||||
s_isUnix ? "/TestDir/ToDelete" : @"C:\TestDir\ToDelete"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DeleteDirectory(pathId)
|
||||
@@ -767,7 +767,7 @@ public class DirectoryServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId pathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/TestDir/NonExistent" : @"C:\TestDir\NonExistent"
|
||||
s_isUnix ? "/TestDir/NonExistent" : @"C:\TestDir\NonExistent"
|
||||
);
|
||||
|
||||
_mockEnvironmentContext.DirectoryProviderService.DeleteDirectory(pathId)
|
||||
|
||||
+29
-29
@@ -34,15 +34,15 @@ public class FileProviderServiceTests
|
||||
private readonly IFileSystemPermissionsService _mockFileSystemPermissionsService;
|
||||
private readonly FileProviderService _sut;
|
||||
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private readonly string _pathVisible1 = s_isLinux ? "/Visible.txt" : @"C:\Visible.txt";
|
||||
private readonly string _pathHidden1 = s_isLinux ? "/Hidden.txt" : @"C:\Hidden.txt";
|
||||
private readonly string _pathValid1 = s_isLinux ? "/Valid.txt" : @"C:\Valid.txt";
|
||||
private readonly string _pathInvalid1 = s_isLinux ? "/Invalid.txt" : @"C:\Invalid.txt";
|
||||
private readonly string _pathSourceFile = s_isLinux ? "/Source/file.txt" : @"C:\Source\file.txt";
|
||||
private readonly string _pathDestinationFile = s_isLinux ? "/Destination/file.txt" : @"C:\Destination\file.txt";
|
||||
private readonly string _pathSource = s_isLinux ? "/Source" : @"C:\Source";
|
||||
private readonly string _pathDestination = s_isLinux ? "/Destination" : @"C:\Destination";
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
private readonly string _pathVisible1 = s_isUnix ? "/Visible.txt" : @"C:\Visible.txt";
|
||||
private readonly string _pathHidden1 = s_isUnix ? "/Hidden.txt" : @"C:\Hidden.txt";
|
||||
private readonly string _pathValid1 = s_isUnix ? "/Valid.txt" : @"C:\Valid.txt";
|
||||
private readonly string _pathInvalid1 = s_isUnix ? "/Invalid.txt" : @"C:\Invalid.txt";
|
||||
private readonly string _pathSourceFile = s_isUnix ? "/Source/file.txt" : @"C:\Source\file.txt";
|
||||
private readonly string _pathDestinationFile = s_isUnix ? "/Destination/file.txt" : @"C:\Destination\file.txt";
|
||||
private readonly string _pathSource = s_isUnix ? "/Source" : @"C:\Source";
|
||||
private readonly string _pathDestination = s_isUnix ? "/Destination" : @"C:\Destination";
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileProviderServiceTests"/> class.
|
||||
@@ -154,10 +154,10 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId();
|
||||
string[] files = s_isLinux
|
||||
string[] files = s_isUnix
|
||||
? ["/C.txt", "/A.txt", "/B.txt"]
|
||||
: [@"C:\C.txt", @"C:\A.txt", @"C:\B.txt"];
|
||||
string[] expectedFiles = s_isLinux
|
||||
string[] expectedFiles = s_isUnix
|
||||
? ["/A.txt", "/B.txt", "/C.txt"]
|
||||
: [@"C:\A.txt", @"C:\B.txt", @"C:\C.txt"];
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.ListDirectory).Returns(true);
|
||||
@@ -625,7 +625,7 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePath = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/NonExistentSource.txt" : @"C:\NonExistentSource.txt"
|
||||
s_isUnix ? "/NonExistentSource.txt" : @"C:\NonExistentSource.txt"
|
||||
);
|
||||
FileSystemPathId destinationPath = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination);
|
||||
bool overrideExisting = false;
|
||||
@@ -737,11 +737,11 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
|
||||
IFileInfo fileInfo = Substitute.For<IFileInfo>();
|
||||
fileInfo.DirectoryName.Returns(parentPath);
|
||||
@@ -764,11 +764,11 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
|
||||
IFileInfo fileInfo = Substitute.For<IFileInfo>();
|
||||
fileInfo.DirectoryName.Returns(parentPath);
|
||||
@@ -790,11 +790,11 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
|
||||
IFileInfo fileInfo = Substitute.For<IFileInfo>();
|
||||
fileInfo.DirectoryName.Returns(parentPath);
|
||||
@@ -817,7 +817,7 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
|
||||
@@ -837,10 +837,10 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
|
||||
IFileInfo fileInfo = Substitute.For<IFileInfo>();
|
||||
fileInfo.DirectoryName.Returns(parentPath);
|
||||
@@ -861,11 +861,11 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
s_isUnix ? "/OldName.txt" : @"C:\OldName.txt"
|
||||
);
|
||||
string newName = "NewName.txt";
|
||||
string parentPath = s_isLinux ? "/" : @"C:\";
|
||||
string newPath = s_isLinux ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
string parentPath = s_isUnix ? "/" : @"C:\";
|
||||
string newPath = s_isUnix ? "/NewName.txt" : @"C:\NewName.txt";
|
||||
|
||||
IFileInfo fileInfo = Substitute.For<IFileInfo>();
|
||||
fileInfo.DirectoryName.Returns(parentPath);
|
||||
@@ -894,7 +894,7 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/FileToDelete.txt" : @"C:\FileToDelete.txt"
|
||||
s_isUnix ? "/FileToDelete.txt" : @"C:\FileToDelete.txt"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete).Returns(true);
|
||||
_mockFileSystem.File.Exists(path.Path).Returns(true);
|
||||
@@ -913,7 +913,7 @@ public class FileProviderServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId path = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/FileToDelete.txt" : @"C:\FileToDelete.txt"
|
||||
s_isUnix ? "/FileToDelete.txt" : @"C:\FileToDelete.txt"
|
||||
);
|
||||
_mockFileSystemPermissionsService.CanAccessPath(path, FileAccessMode.Delete).Returns(false);
|
||||
|
||||
|
||||
+15
-15
@@ -34,20 +34,20 @@ public class FileServiceTests
|
||||
private readonly FileService _sut;
|
||||
private readonly FileSystemPathIdFixture _fileSystemPathIdFixture;
|
||||
private readonly FileFixture _fileFixture;
|
||||
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
|
||||
private readonly string _pathTestDir = s_isLinux ? "/TestDir" : @"C:\TestDir";
|
||||
private readonly string _pathTestDirFile1 = s_isLinux ? "/TestDir/File1.txt" : @"C:\TestDir\File1.txt";
|
||||
private readonly string _pathTestDirFile2 = s_isLinux ? "/TestDir/File2.txt" : @"C:\TestDir\File2.txt";
|
||||
private readonly string _pathTestDirInaccessible = s_isLinux ? "/TestDir/InaccessibleFile.txt" : @"C:\TestDir\InaccessibleFile.txt";
|
||||
private readonly string _pathDestination1 = s_isLinux ? "/Destination/" : @"C:\Destination\";
|
||||
private readonly string _pathDestination2 = s_isLinux ? "/Destination" : @"C:\Destination";
|
||||
private readonly string _pathSourceFile = s_isLinux ? "/Source/file.txt" : @"C:\Source\file.txt";
|
||||
private readonly string _pathDestinationFile = s_isLinux ? "/Destination/file.txt" : @"C:\Destination\file.txt";
|
||||
private readonly string _pathSourceOldFile = s_isLinux ? "/Source/oldfile.txt" : @"C:\Source\oldfile.txt";
|
||||
private readonly string _pathSourceNewFile = s_isLinux ? "/Source/newfile.txt" : @"C:\Source\newfile.txt";
|
||||
private readonly string _pathSourceExistingFile = s_isLinux ? "/Source/existingfile.txt" : @"C:\Source\existingfile.txt";
|
||||
private readonly string _pathSourceNonExistingFile = s_isLinux ? "/Source/nonexistent.txt" : @"C:\Source\nonexistent.txt";
|
||||
private readonly char _dirSeparator = s_isLinux ? '/' : '\\';
|
||||
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
|
||||
private readonly string _pathTestDir = s_isUnix ? "/TestDir" : @"C:\TestDir";
|
||||
private readonly string _pathTestDirFile1 = s_isUnix ? "/TestDir/File1.txt" : @"C:\TestDir\File1.txt";
|
||||
private readonly string _pathTestDirFile2 = s_isUnix ? "/TestDir/File2.txt" : @"C:\TestDir\File2.txt";
|
||||
private readonly string _pathTestDirInaccessible = s_isUnix ? "/TestDir/InaccessibleFile.txt" : @"C:\TestDir\InaccessibleFile.txt";
|
||||
private readonly string _pathDestination1 = s_isUnix ? "/Destination/" : @"C:\Destination\";
|
||||
private readonly string _pathDestination2 = s_isUnix ? "/Destination" : @"C:\Destination";
|
||||
private readonly string _pathSourceFile = s_isUnix ? "/Source/file.txt" : @"C:\Source\file.txt";
|
||||
private readonly string _pathDestinationFile = s_isUnix ? "/Destination/file.txt" : @"C:\Destination\file.txt";
|
||||
private readonly string _pathSourceOldFile = s_isUnix ? "/Source/oldfile.txt" : @"C:\Source\oldfile.txt";
|
||||
private readonly string _pathSourceNewFile = s_isUnix ? "/Source/newfile.txt" : @"C:\Source\newfile.txt";
|
||||
private readonly string _pathSourceExistingFile = s_isUnix ? "/Source/existingfile.txt" : @"C:\Source\existingfile.txt";
|
||||
private readonly string _pathSourceNonExistingFile = s_isUnix ? "/Source/nonexistent.txt" : @"C:\Source\nonexistent.txt";
|
||||
private readonly char _dirSeparator = s_isUnix ? '/' : '\\';
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="FileServiceTests"/> class.
|
||||
@@ -742,7 +742,7 @@ public class FileServiceTests
|
||||
{
|
||||
// Arrange
|
||||
FileSystemPathId sourcePathId = _fileSystemPathIdFixture.CreateFileSystemPathId(
|
||||
s_isLinux ? "/Source/nonexistent.txt" : _pathSourceNonExistingFile
|
||||
s_isUnix ? "/Source/nonexistent.txt" : _pathSourceNonExistingFile
|
||||
);
|
||||
FileSystemPathId destinationPathId = _fileSystemPathIdFixture.CreateFileSystemPathId(_pathDestination2);
|
||||
bool overrideExisting = true;
|
||||
|
||||
Reference in new issue
Block a user