public void ReallySwapActivePlayers_AfterMiss() { var target = new CellPosition(5, 6); A.CallTo(() => player2.SelfField.Shoot(target)).Returns(ShotResult.Miss(target)); A.CallTo(() => player2.SelfField.SurvivedShips.Values).Returns(new[] { 1 }); gameController.Shoot(target); var knowledge = new GameFieldKnowledge(gameController.Rules.FieldSize); A.CallTo(() => player2.OpponentFieldKnowledge).Returns(knowledge); var affectedCells = new[] { new CellPosition(2, 2), new CellPosition(1, 8) }; A.CallTo(() => player1.SelfField.Shoot(target)).Returns(ShotResult.Hit(target, affectedCells)); gameController.Shoot(target); foreach (var position in knowledge.EnumeratePositions()) { var expected = position.Equals(target) ? true : (affectedCells.Contains(position) ? (bool?)false : null); knowledge[position].Should().Be(expected); } }
public void RememberAffectedCellsAndTarget_InOpponentKnowlendge_AfterHit() { var knowledge = new GameFieldKnowledge(gameController.Rules.FieldSize); A.CallTo(() => player1.OpponentFieldKnowledge).Returns(knowledge); var target = new CellPosition(5, 6); var affectedCells = new[] { new CellPosition(0, 0), new CellPosition(4, 4), new CellPosition(6, 6) }; var shotResult = ShotResult.Hit(target, affectedCells); A.CallTo(() => player2.SelfField.Shoot(target)).Returns(shotResult); gameController.Shoot(target).Should().Be(shotResult); foreach (var position in knowledge.EnumeratePositions()) { var expected = position.Equals(target) ? true : (affectedCells.Contains(position) ? (bool?)false : null); knowledge[position].Should().Be(expected); } }