forked from cake-build/cake
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFakeFileSystem.cs
More file actions
65 lines (59 loc) · 2.38 KB
/
FakeFileSystem.cs
File metadata and controls
65 lines (59 loc) · 2.38 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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Cake.Core;
using Cake.Core.IO;
namespace Cake.Testing
{
/// <summary>
/// Represents a fake file system.
/// </summary>
public sealed class FakeFileSystem : IFileSystem
{
private readonly FakeFileSystemTree _tree;
/// <summary>
/// Initializes a new instance of the <see cref="FakeFileSystem"/> class.
/// </summary>
/// <param name="environment">The environment.</param>
public FakeFileSystem(ICakeEnvironment environment)
{
_tree = new FakeFileSystemTree(environment);
}
/// <summary>
/// Gets a <see cref="FakeFile"/> instance representing the specified path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>A <see cref="FakeFile"/> instance representing the specified path.</returns>
public FakeFile GetFile(FilePath path)
{
return _tree.FindFile(path) ?? new FakeFile(_tree, path);
}
/// <summary>
/// Gets a <see cref="FakeDirectory" /> instance representing the specified path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>A <see cref="FakeDirectory" /> instance representing the specified path.</returns>
public FakeDirectory GetDirectory(DirectoryPath path)
{
return _tree.FindDirectory(path) ?? new FakeDirectory(_tree, path);
}
/// <summary>
/// Gets a <see cref="IDirectory" /> instance representing the specified path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>A <see cref="IDirectory" /> instance representing the specified path.</returns>
IDirectory IFileSystem.GetDirectory(DirectoryPath path)
{
return GetDirectory(path);
}
/// <summary>
/// Gets a <see cref="IFile" /> instance representing the specified path.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>A <see cref="IFile" /> instance representing the specified path.</returns>
IFile IFileSystem.GetFile(FilePath path)
{
return GetFile(path);
}
}
}