-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e612c66
commit 02e1069
Showing
7 changed files
with
267 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
namespace Spectre.IO.Testing; | ||
|
||
/// <summary> | ||
/// Represents a fake machine. | ||
/// </summary> | ||
public sealed class FakeMachine : IMachine | ||
{ | ||
/// <summary> | ||
/// Gets the fake file system. | ||
/// </summary> | ||
public FakeFileSystem FileSystem { get; } | ||
|
||
/// <summary> | ||
/// Gets the fake environment. | ||
/// </summary> | ||
public FakeEnvironment Environment { get; } | ||
|
||
/// <inheritdoc/> | ||
IFileSystem IMachine.FileSystem => FileSystem; | ||
|
||
/// <inheritdoc/> | ||
IEnvironment IMachine.Environment => Environment; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="FakeMachine"/> class. | ||
/// </summary> | ||
/// <param name="family">The platform family.</param> | ||
/// <param name="architecture">The platform processor architecture.</param> | ||
public FakeMachine( | ||
PlatformFamily family, | ||
PlatformArchitecture architecture = PlatformArchitecture.X64) | ||
{ | ||
Environment = new FakeEnvironment(family, architecture); | ||
FileSystem = new FakeFileSystem(Environment); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a Linux machine. | ||
/// </summary> | ||
/// <param name="architecture">The platform processor architecture.</param> | ||
/// <returns>A Linux environment.</returns> | ||
public static FakeMachine CreateLinuxMachine(PlatformArchitecture architecture = PlatformArchitecture.X64) | ||
{ | ||
return new FakeMachine(PlatformFamily.Linux, architecture); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a macOS environment. | ||
/// </summary> | ||
/// <param name="architecture">The platform processor architecture.</param> | ||
/// <returns>A macOS environment.</returns> | ||
public static FakeMachine CreateMacOsMachine(PlatformArchitecture architecture = PlatformArchitecture.X64) | ||
{ | ||
return new FakeMachine(PlatformFamily.MacOs, architecture); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a Windows environment. | ||
/// </summary> | ||
/// <param name="architecture">The platform processor architecture.</param> | ||
/// <returns>A Windows environment.</returns> | ||
public static FakeMachine CreateWindowsMachine(PlatformArchitecture architecture = PlatformArchitecture.X64) | ||
{ | ||
return new FakeMachine(PlatformFamily.Windows, architecture); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a FreeBSD environment. | ||
/// </summary> | ||
/// <param name="architecture">The platform processor architecture.</param> | ||
/// <returns>A Windows environment.</returns> | ||
public static FakeMachine CreateFreeBsdMachine(PlatformArchitecture architecture = PlatformArchitecture.X64) | ||
{ | ||
return new FakeMachine(PlatformFamily.FreeBSD, architecture); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
namespace Spectre.IO; | ||
|
||
/// <summary> | ||
/// Contains extensions for <see cref="IMachine"/>. | ||
/// </summary> | ||
public static class IMachineExtensions | ||
{ | ||
/// <summary> | ||
/// Creates a new <see cref="IGlobber"/> instance. | ||
/// </summary> | ||
/// <param name="machine">The machine to base the globber on.</param> | ||
/// <returns>A <see cref="IGlobber"/> instance.</returns> | ||
public static IGlobber CreateGlobber(this IMachine machine) | ||
{ | ||
return new Globber(machine.FileSystem, machine.Environment); | ||
} | ||
} |
Oops, something went wrong.