public void SimulateMove_WithoutCollisions(string input, string command, string expectedResult) { var pod = StateReader.ReadPod(input); var move = PodMove.Parse(command); throw new NotImplementedException("Finish this test! Put here simulation of one tick of the pod move without collisions"); Assert.AreEqual(expectedResult, pod.ToString()); }
public void TickCorrectly( string init, string state1, string move1, string move2, string move3, string move4, string state2) { var state = StateReader.Read(init, state1); var myMoves = new[] { PodMove.Parse(move1), PodMove.Parse(move2) }; var hisMoves = new[] { PodMove.Parse(move3), PodMove.Parse(move4) }; state.Tick(myMoves, hisMoves); var expectedState = StateReader.Read(init, state2); EnsureAlmostEqual(state, expectedState); }
public void SimulateGameLogCorrectly(string filename) { var lines = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, filename)); var iLine = 0; var initData = new StateReader(lines[iLine++]).ReadInitData(); var persister = new StatePersister(); var tick = 0; State prevStateAfterMovesApplied = null; while (iLine < lines.Length) { var state = new StateReader(lines[iLine++]).ReadState(initData, persister.IsInitialState); persister.FillState(state); if (prevStateAfterMovesApplied != null) { try { EnsureAlmostEqual(prevStateAfterMovesApplied, state); } catch { Console.Error.WriteLine(" simulation result: "); Console.Error.WriteLine(prevStateAfterMovesApplied); Console.Error.WriteLine(" true result:"); Console.Error.WriteLine(state); throw; } } iLine++; // ReSharper disable once AccessToModifiedClosure var myMoves = 2.Times(i => PodMove.Parse(lines[iLine++])).ToArray(); var hisMoves = 2.Times(i => PodMove.Parse(lines[iLine++])).ToArray(); Console.Error.WriteLine($"=== TICK {tick} ==="); Console.Error.WriteLine(state); Console.Error.WriteLine("myPod[0]: " + myMoves[0]); Console.Error.WriteLine("myPod[1]: " + myMoves[1]); Console.Error.WriteLine("hisPod[0]: " + hisMoves[0]); Console.Error.WriteLine("hisPod[1]: " + hisMoves[1]); state.Tick(myMoves, hisMoves); persister.RegisterMoves(myMoves, hisMoves); prevStateAfterMovesApplied = state; tick++; } }