diff --git a/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs b/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs index f1d5c8e..0efeedd 100644 --- a/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs +++ b/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs @@ -51,6 +51,31 @@ public sealed class SimulationEngineTests Assert.True(next.GetCell(new(2, 3)).Hazards.Smoke > 0); } + [Fact] + public void AdvanceTurnRunsConfiguredCellEffects() + { + var engine = new SimulationEngine([new TestCellEffect()], [], []); + var level = LevelState.Create("Custom effect", 6, 6) + .SetCell(new(2, 2), new() { + Hazards = new() { Heat = 1 } + }); + + var next = engine.AdvanceTurn(level); + + Assert.Equal(5, next.GetCell(new(2, 2)).Hazards.Heat); + } + + [Fact] + public void AdvanceTurnRunsConfiguredAreaEffects() + { + var engine = new SimulationEngine([], [new TestAreaEffect()], []); + var level = LevelState.Create("Custom area effect", 6, 6); + + var next = engine.AdvanceTurn(level); + + Assert.Equal(7, next.GetCell(new(2, 2)).Hazards.Smoke); + } + [Fact] public void OverpressurePredictsPipeBurst() { @@ -174,4 +199,24 @@ public sealed class SimulationEngineTests yield return new(EFailureKind.PipeBurst, new(turns, 0), turns, $"STEP {turns}"); } } + + private sealed class TestCellEffect : ISimulationEffect + { + public CellState Apply(CellState cell) + { + return cell with { Hazards = cell.Hazards with { Heat = 5 } }; + } + } + + private sealed class TestAreaEffect : IAreaSimulationEffect + { + public CellState[] Apply(LevelState level, CellState[] cells) + { + var next = cells.ToArray(); + var position = new GridPosition(2, 2); + var cell = next[level.Index(position)]; + next[level.Index(position)] = cell with { Hazards = cell.Hazards with { Smoke = 7 } }; + return next; + } + } } \ No newline at end of file