mirror of
https://github.com/MaSzyna-EU07/StarterNG.git
synced 2026-10-16 23:49:19 +02:00
Move rolling stock and physics into the domain
VehicleDatabase becomes VehicleCatalog, Physics becomes VehiclePhysics, and the textures.txt and .fiz parsers move to Infrastructure. GameLibrary replaces the GameData singleton.
This commit is contained in:
@@ -92,6 +92,17 @@ public sealed class InMemoryFileSystem : IFileSystem
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> GetFilesRecursive(string path, string searchPattern)
|
||||
{
|
||||
string prefix = Normalize(path) + "/";
|
||||
var pattern = ToRegex(searchPattern);
|
||||
return _files.Keys
|
||||
.Where(key => key.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
||||
.Where(key => pattern.IsMatch(key[(key.LastIndexOf('/') + 1)..]))
|
||||
.OrderBy(key => key, StringComparer.OrdinalIgnoreCase)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public IReadOnlyList<string> GetDirectories(string path)
|
||||
{
|
||||
string prefix = Normalize(path) + "/";
|
||||
|
||||
48
StarterNG.Tests/Fakes/TestInstallation.cs
Normal file
48
StarterNG.Tests/Fakes/TestInstallation.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using StarterNG.Application;
|
||||
using StarterNG.Infrastructure.Adapters;
|
||||
using StarterNG.Infrastructure.Sceneries;
|
||||
using StarterNG.Infrastructure.Vehicles;
|
||||
|
||||
namespace StarterNG.Tests.Fakes;
|
||||
|
||||
/// <summary>
|
||||
/// The production object graph wired over an in-memory installation: the same
|
||||
/// composition as <c>AppServices</c>, with disk, clock and randomness replaced.
|
||||
/// </summary>
|
||||
public sealed class TestInstallation
|
||||
{
|
||||
public const string Root = "game";
|
||||
|
||||
public TestInstallation(InMemoryFileSystem? files = null, DateTime? now = null)
|
||||
{
|
||||
Files = files ?? new InMemoryFileSystem();
|
||||
Paths = new GamePaths(Root);
|
||||
Clock = new FixedClock(now ?? new DateTime(2026, 1, 1, 12, 0, 0));
|
||||
Random = new StubRandom();
|
||||
Log = new FileDiagnosticsLog(Files, Clock, Paths);
|
||||
Strings = new FakeStrings();
|
||||
|
||||
MiniTextures = new MiniTextureIndex(Files, Paths);
|
||||
Physics = new FizPhysicsRepository(Files, Paths, Log);
|
||||
Vehicles = new TexturesTxtVehicleRepository(Files, Paths, Log, new TexturesTxtParser());
|
||||
Sceneries = new SceneryRepository(Files, Paths, Log, new SceneryParser(Clock, Random));
|
||||
MissingAssets = new MissingAssetScanner(Files, Paths);
|
||||
Library = new GameLibrary(Vehicles, Sceneries, MiniTextures, Physics, Log);
|
||||
}
|
||||
|
||||
public InMemoryFileSystem Files { get; }
|
||||
public GamePaths Paths { get; }
|
||||
public FixedClock Clock { get; }
|
||||
public StubRandom Random { get; }
|
||||
public FileDiagnosticsLog Log { get; }
|
||||
public FakeStrings Strings { get; }
|
||||
public MiniTextureIndex MiniTextures { get; }
|
||||
public FizPhysicsRepository Physics { get; }
|
||||
public TexturesTxtVehicleRepository Vehicles { get; }
|
||||
public SceneryRepository Sceneries { get; }
|
||||
public MissingAssetScanner MissingAssets { get; }
|
||||
public GameLibrary Library { get; }
|
||||
|
||||
/// <summary>Path of a file inside the fake installation.</summary>
|
||||
public static string At(params string[] segments) => Path.Combine(new[] { Root }.Concat(segments).ToArray());
|
||||
}
|
||||
Reference in New Issue
Block a user