public void CountCatchableByPiece_ThereIsTwoEnemyPieceAround_CatchableCountTwo() { var target = new CheckersBoard(8); var piece = target.GetSquare(3, 2).CurrentPiece; Assert.AreEqual(0, target.CountCatchableByPiece(piece)); var enemyPiece1 = target.GetSquare(6, 5).CurrentPiece; Assert.AreEqual(0, target.CountCatchableByPiece(piece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece1)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece1, target.GetSquare(5, 4)))); Assert.AreEqual(0, target.CountCatchableByPiece(piece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece1)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece1, target.GetSquare(4, 3)))); Assert.AreEqual(1, target.CountCatchableByPiece(piece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece1)); var enemyPiece2 = target.GetSquare(4, 5).CurrentPiece; Assert.AreEqual(1, target.CountCatchableByPiece(piece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece2)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece2, target.GetSquare(3, 4)))); Assert.AreEqual(1, target.CountCatchableByPiece(piece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece2)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece2, target.GetSquare(2, 3)))); Assert.AreEqual(2, target.CountCatchableByPiece(piece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece2)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece1)); }
public void CountCatchableByPiece_ThereIsEnemyPieceAround_CatchableCount() { 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.CountCatchableByPiece(piece)); Assert.IsTrue(target.MovePiece(new CheckersMove(piece, target.GetSquare(3, 4)))); Assert.AreEqual(0, target.CountCatchableByPiece(piece)); var enemyPiece = target.GetSquare(4, 5).CurrentPiece; Assert.AreEqual(1, target.CountCatchableByPiece(enemyPiece)); Assert.AreEqual(0, target.CountCatchableByPiece(piece)); Assert.IsTrue(target.MovePiece(new CheckersMove(enemyPiece, target.GetSquare(2, 3)))); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece)); var otherPiece = target.GetSquare(2, 1).CurrentPiece; Assert.IsTrue(target.MovePiece(new CheckersMove(otherPiece, target.GetSquare(1, 2)))); Assert.AreEqual(1, target.CountCatchableByPiece(otherPiece)); Assert.AreEqual(0, target.CountCatchableByPiece(enemyPiece)); }
public void CountCatchableByPiece_ThereIsNoEnemyPieceAround_Zero() { var target = new CheckersBoard(8); foreach (var p in target.PlayerOnePieces) { Assert.AreEqual(0, target.CountCatchableByPiece(p)); } foreach (var p in target.PlayerTwoPieces) { Assert.AreEqual(0, target.CountCatchableByPiece(p)); } }
public void CountCatchableByPiece_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.CountCatchableByPiece(piece)); Assert.IsTrue(target.MovePiece(new CheckersMove(piece, target.GetSquare(3, 4)))); Assert.AreEqual(0, target.CountCatchableByPiece(piece)); Assert.IsFalse(target.MovePiece(new CheckersMove(piece, target.GetSquare(4, 5)))); Assert.AreEqual(0, target.CountCatchableByPiece(piece)); }
public void CountCatchableByPiece_Null_Exception() { var target = new CheckersBoard(8); ExceptionAssert.IsThrowing(new ArgumentNullException("piece"), () => { target.CountCatchableByPiece(null); }); }