public void CountCapturableByPiece_ThereIsNoEnemyPieceAround_Zero() { var target = new CheckersBoard(8); foreach (var p in target.PlayerOnePieces) { Assert.AreEqual(0, target.CountCapturableByPiece(p)); } foreach (var p in target.PlayerTwoPieces) { Assert.AreEqual(0, target.CountCapturableByPiece(p)); } }
public void CountCapturableByPiece_ThereIsEnemyPieceAroundButCannotBeCaptured_Zero() { var target = new CheckersBoard(8); var piece = target.GetSquare(1, 2).CurrentPiece; Assert.IsTrue(target.MovePiece(new CheckersMove(piece, target.GetSquare(2, 3)))); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); Assert.IsTrue(target.MovePiece(new CheckersMove(piece, target.GetSquare(3, 4)))); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); Assert.IsFalse(target.MovePiece(new CheckersMove(piece, target.GetSquare(4, 5)))); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); }
public void CountCapturableByPiece_ThereIsEnemyPieceAround_CapturableCount() { var target = new CheckersBoard(8); var piece = target.GetSquare(1, 2).CurrentPiece; Assert.IsTrue(target.MovePiece(new CheckersMove(piece, target.GetSquare(2, 3)))); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); Assert.IsTrue(target.MovePiece(new CheckersMove(piece, target.GetSquare(3, 4)))); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); var enemyPiece = target.GetSquare(4, 5).CurrentPiece; Assert.AreEqual(1, target.CountCapturableByPiece(enemyPiece)); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece, target.GetSquare(2, 3)))); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece)); var otherPiece = target.GetSquare(2, 1).CurrentPiece; Assert.IsTrue(target.MovePiece(new CheckersMove(otherPiece, target.GetSquare(1, 2)))); Assert.AreEqual(1, target.CountCapturableByPiece(otherPiece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece)); }
public void CountCapturableByPiece_Null_Exception() { var target = new CheckersBoard(8); ExceptionAssert.IsThrowing(new ArgumentNullException("piece"), () => { target.CountCapturableByPiece(null); }); }
public void CountCapturableByPiece_ThereIsTwoEnemyPieceAround_CapturableCountTwo() { var target = new CheckersBoard(8); var piece = target.GetSquare(3, 2).CurrentPiece; Assert.AreEqual(0, target.CountCapturableByPiece(piece)); var enemyPiece1 = target.GetSquare(6, 5).CurrentPiece; Assert.AreEqual(0, target.CountCapturableByPiece(piece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece1)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece1, target.GetSquare(5, 4)))); Assert.AreEqual(0, target.CountCapturableByPiece(piece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece1)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece1, target.GetSquare(4, 3)))); Assert.AreEqual(1, target.CountCapturableByPiece(piece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece1)); var enemyPiece2 = target.GetSquare(4, 5).CurrentPiece; Assert.AreEqual(1, target.CountCapturableByPiece(piece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece2)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece2, target.GetSquare(3, 4)))); Assert.AreEqual(1, target.CountCapturableByPiece(piece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece2)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece2, target.GetSquare(2, 3)))); Assert.AreEqual(2, target.CountCapturableByPiece(piece)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece2)); Assert.AreEqual(0, target.CountCapturableByPiece(enemyPiece1)); }