mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-11-05 21:29:09 +01:00
Split Settings into model, serializer, paths and store
698 lines did all of it at once. The mutable CaptureFromUi callback becomes an ISettingsCapture the settings view implements.
This commit is contained in:
34
StarterNG.Tests/Fakes/FakeEnvironment.cs
Normal file
34
StarterNG.Tests/Fakes/FakeEnvironment.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using StarterNG.Application.Abstractions;
|
||||
|
||||
namespace StarterNG.Tests.Fakes;
|
||||
|
||||
/// <summary>A host machine described inline: platform, home folder, env vars.</summary>
|
||||
public sealed class FakeEnvironment : IEnvironment
|
||||
{
|
||||
private readonly Dictionary<string, string> _variables = new(StringComparer.Ordinal);
|
||||
|
||||
public bool IsWindows { get; set; }
|
||||
|
||||
public bool IsLinux { get; set; } = true;
|
||||
|
||||
public bool IsMacOS { get; set; }
|
||||
|
||||
public string BaseDirectory { get; set; } = Path.Combine("game");
|
||||
|
||||
public string? GetVariable(string name) => _variables.TryGetValue(name, out var value) ? value : null;
|
||||
|
||||
public FakeEnvironment With(string name, string value)
|
||||
{
|
||||
_variables[name] = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>Switches the fake to Windows, with an APPDATA folder.</summary>
|
||||
public FakeEnvironment AsWindows(string appData = "C:/Users/kolejarz/AppData/Roaming")
|
||||
{
|
||||
IsWindows = true;
|
||||
IsLinux = false;
|
||||
IsMacOS = false;
|
||||
return With("APPDATA", appData);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user