using System; using System.Collections.Generic; using Robust.Shared.Configuration; using Robust.Shared.IoC; using Robust.Shared.Log; using Robust.Shared.Timing; namespace Robust.UnitTesting; /// /// Creates implementations of common engine interfaces for use in unit tests. /// public static class MockInterfaces { /// /// Creates an instance of . /// /// The timing service used. /// The log service used. /// /// Whether this configuration manager will treat itself as server or client. /// This is only relevant for CVars that are defined as or . /// /// /// A list of additional types to pull CVar definitions from. /// These normally have . /// public static IConfigurationManager MakeConfigurationManager( IGameTiming gameTiming, ILogManager logManager, bool isServer = true, IEnumerable? loadCvarsFromTypes = null) { var deps = new DependencyCollection(); deps.RegisterInstance(gameTiming); deps.RegisterInstance(logManager); deps.Register(); deps.BuildGraph(); var cfg = deps.Resolve(); cfg.Initialize(isServer); if (loadCvarsFromTypes != null) { foreach (var loadFromType in loadCvarsFromTypes) { cfg.LoadCVarsFromType(loadFromType); } } return cfg; } }