-
Notifications
You must be signed in to change notification settings - Fork 68
Expand file tree
/
Copy pathFileSystemRunner.cs
More file actions
116 lines (102 loc) · 5.36 KB
/
FileSystemRunner.cs
File metadata and controls
116 lines (102 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using NUnit.Framework;
using System;
namespace Scalar.FunctionalTests.FileSystemRunners
{
public abstract class FileSystemRunner
{
private static FileSystemRunner defaultRunner = new SystemIORunner();
public static object[] AllWindowsRunners { get; } =
new[]
{
new object[] { new SystemIORunner() },
new object[] { new CmdRunner() },
new object[] { new PowerShellRunner() },
new object[] { new BashRunner() },
};
public static object[] AllMacRunners { get; } =
new[]
{
new object[] { new SystemIORunner() },
new object[] { new BashRunner() },
};
public static object[] DefaultRunners { get; } =
new[]
{
new object[] { defaultRunner }
};
public static object[] Runners
{
get { return ScalarTestConfig.FileSystemRunners; }
}
/// <summary>
/// Default runner to use (for tests that do not need to be run with multiple runners)
/// </summary>
public static FileSystemRunner DefaultRunner
{
get { return defaultRunner; }
}
// File methods
public abstract bool FileExists(string path);
public abstract string MoveFile(string sourcePath, string targetPath);
/// <summary>
/// Attempt to move the specified file to the specifed target path. By calling this method the caller is
/// indicating that they expect the move to fail. However, the caller is responsible for verifying that
/// the move failed.
/// </summary>
/// <param name="sourcePath">Path to existing file</param>
/// <param name="targetPath">Path to target file (target of the move)</param>
public abstract void MoveFileShouldFail(string sourcePath, string targetPath);
public abstract void MoveFile_FileShouldNotBeFound(string sourcePath, string targetPath);
public abstract string ReplaceFile(string sourcePath, string targetPath);
public abstract void ReplaceFile_FileShouldNotBeFound(string sourcePath, string targetPath);
public abstract string DeleteFile(string path);
public abstract void DeleteFile_FileShouldNotBeFound(string path);
public abstract void DeleteFile_AccessShouldBeDenied(string path);
public abstract string ReadAllText(string path);
public abstract void ReadAllText_FileShouldNotBeFound(string path);
public abstract void CreateEmptyFile(string path);
public abstract void CreateHardLink(string newLinkFilePath, string existingFilePath);
public abstract void ChangeMode(string path, ushort mode);
/// <summary>
/// Write the specified contents to the specified file. By calling this method the caller is
/// indicating that they expect the write to succeed. However, the caller is responsible for verifying that
/// the write succeeded.
/// </summary>
/// <param name="path">Path to file</param>
/// <param name="contents">File contents</param>
public abstract void WriteAllText(string path, string contents);
public abstract IDisposable OpenFileAndWrite(string path, string data);
/// <summary>
/// Append the specified contents to the specified file. By calling this method the caller is
/// indicating that they expect the write to succeed. However, the caller is responsible for verifying that
/// the write succeeded.
/// </summary>
/// <param name="path">Path to file</param>
/// <param name="contents">File contents</param>
public abstract void AppendAllText(string path, string contents);
/// <summary>
/// Attempt to write the specified contents to the specified file. By calling this method the caller is
/// indicating that they expect the write to fail. However, the caller is responsible for verifying that
/// the write failed.
/// </summary>
/// <typeparam name="ExceptionType">Expected type of exception to be thrown</typeparam>
/// <param name="path">Path to file</param>
/// <param name="contents">File contents</param>
public abstract void WriteAllTextShouldFail<ExceptionType>(string path, string contents) where ExceptionType : Exception;
// Directory methods
public abstract bool DirectoryExists(string path);
public abstract void MoveDirectory(string sourcePath, string targetPath);
public abstract void RenameDirectory(string workingDirectory, string source, string target);
public abstract void MoveDirectory_RequestShouldNotBeSupported(string sourcePath, string targetPath);
public abstract void MoveDirectory_TargetShouldBeInvalid(string sourcePath, string targetPath);
public abstract void CreateDirectory(string path);
public abstract string EnumerateDirectory(string path);
public abstract long FileSize(string path);
/// <summary>
/// A recursive delete of a directory
/// </summary>
public abstract string DeleteDirectory(string path);
public abstract void DeleteDirectory_DirectoryShouldNotBeFound(string path);
public abstract void DeleteDirectory_ShouldBeBlockedByProcess(string path);
}
}