using StarterNG.Application; using StarterNG.Infrastructure.Adapters; using StarterNG.Infrastructure.Sceneries; using StarterNG.Infrastructure.Settings; using StarterNG.Infrastructure.Vehicles; namespace StarterNG.Tests.Fakes; /// /// The production object graph wired over an in-memory installation: the same /// composition as AppServices, with disk, clock and randomness replaced. /// 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()); VehicleJson = new VehicleJsonSerializer(); Sceneries = new SceneryRepository(Files, Paths, Log, new SceneryParser(Clock, Random)); MissingAssets = new MissingAssetScanner(Files, Paths); Environment = new FakeEnvironment(); SettingsPaths = new SettingsPaths(Environment, Paths); VehicleCache = new VehicleCacheRepository(Files, Paths, Log, Vehicles, VehicleJson, SettingsPaths.VehicleCacheDirectory()); Library = new GameLibrary(VehicleCache, Sceneries, MiniTextures, Physics, Log); Executables = new ExecutableLocator(Files, Paths, Environment, Log); SettingsStore = new SettingsStore(Files, Clock, Log, SettingsPaths, new SettingsSerializer(), Executables); } 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 VehicleJsonSerializer VehicleJson { get; } public VehicleCacheRepository VehicleCache { get; } public SceneryRepository Sceneries { get; } public MissingAssetScanner MissingAssets { get; } public GameLibrary Library { get; } public FakeEnvironment Environment { get; } public SettingsPaths SettingsPaths { get; } public ExecutableLocator Executables { get; } public SettingsStore SettingsStore { get; } /// Path of a file inside the fake installation. public static string At(params string[] segments) => Path.Combine(new[] { Root }.Concat(segments).ToArray()); }