parent
bf7d884183
commit
da38fd597f
@ -0,0 +1,20 @@
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TestLibrary;
|
||||
|
||||
public static class FileUtils
|
||||
{
|
||||
public static ICollection<string> NormalizePaths(IEnumerable<string> paths)
|
||||
=> paths.Select(NormalizePath).ToList();
|
||||
|
||||
public static string NormalizePath(string path)
|
||||
{
|
||||
if (MockUnixSupport.IsUnixPlatform())
|
||||
{
|
||||
return Regex.Replace(path, @"^C:\\", "/").Replace("\\", "/");
|
||||
}
|
||||
|
||||
return Regex.Replace(path, @"^/", @"C:\").Replace("/", "\\");
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
|
||||
namespace TestLibrary;
|
||||
|
||||
public static class MockFileSystemExtensions
|
||||
{
|
||||
public static void AddFileNoData(this MockFileSystem fs, string path)
|
||||
{
|
||||
fs.AddFile(FileUtils.NormalizePath(path), new MockFileData(""));
|
||||
}
|
||||
|
||||
public static void AddDirectory2(this MockFileSystem fs, string path)
|
||||
{
|
||||
fs.AddDirectory(FileUtils.NormalizePath(path));
|
||||
}
|
||||
}
|
Loading…
Reference in new issue