using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Threading; using MultiWheelC.TrajectoryPlanning.EMPlanner; namespace EMPlannerVerificationHost; internal sealed class FakeQpSolver : IQpSolver { private readonly QpSolveResult _result; public FakeQpSolver(QpSolveResult result) { _result = result ?? throw new ArgumentNullException(nameof(result)); LastWarmStart = Array.Empty(); } public QuadraticProgram? LastProblem { get; private set; } public QpSolverSettings? LastSettings { get; private set; } public IReadOnlyList LastWarmStart { get; private set; } public QpSolveResult Solve(QuadraticProgram problem, QpSolverSettings settings, IReadOnlyList warmStart, CancellationToken cancellationToken) { LastProblem = problem ?? throw new ArgumentNullException(nameof(problem)); LastSettings = settings ?? throw new ArgumentNullException(nameof(settings)); var copy = new List(warmStart == null ? 0 : warmStart.Count); if (warmStart != null) { for (int index = 0; index < warmStart.Count; index++) copy.Add(warmStart[index]); } LastWarmStart = new ReadOnlyCollection(copy); return _result; } }