public void GivenCleanExtraProbabilityOf1_Suck_ShouldCleanAdjacentSquare() { // arrange _state.SetAllSquaresDirty(); _state.VacuumPos = new Point2D(1, 1); const double cleanExtraProbability = 1.0; _handler = new ErraticSuckActionHandler(_decoratedHandler, cleanExtraProbability); // act _handler.DoAction(_state, VacuumWorldAction.Suck); // assert var numDirtyNeighbours = _state.AdjacentSquares(_state.VacuumPos).Count(s => _state.SquareIsDirty(s)); Assert.AreEqual(3, numDirtyNeighbours); }
public void GivenAllSquaresAreDirty_Suck_ShouldReturnCleanedStatePlusCleanedNeighbourStates() { var currentState = new VacuumWorldState(3); currentState.SetAllSquaresDirty(); currentState.VacuumPos = new Point2D(1, 1); var onlyOneSquareCleanedState = currentState.Clone(); onlyOneSquareCleanedState.CleanSquare(currentState.VacuumPos); var neighbourCleanedStates = CreateAllStatesWithOneCleanedNeighbour(onlyOneSquareCleanedState); var expectedPotentialStates = neighbourCleanedStates .Concat(new[] { onlyOneSquareCleanedState }).ToList(); // act var potentialStates = _searchProblem.DoAction(currentState, VacuumWorldAction.Suck).ToList(); // assert CollectionAssert.AreEquivalent(expectedPotentialStates, potentialStates); }