Пример #1
0
 public void TestChestSymbolGetter()
 {
     char excpected = 'K';
     ChessPiece testPiece = new ChessPiece(excpected, 2, 3);
     bool check = testPiece.Symbol == excpected;
     Assert.IsTrue(check);
 }
Пример #2
0
 public void TestChestPieceSecondaryConstructorX()
 {
     char excpected = 'K';
     ChessPiece testPiece = new ChessPiece(excpected, 2 ,3);
     int x = 2;
     Assert.AreEqual(x, testPiece.XCoord);
 }
Пример #3
0
 public void TestChestPieceSecondaryConstructorY()
 {
     char excpected = 'K';
     ChessPiece testPiece = new ChessPiece(excpected, 2, 3);
     int y = 3;
     Assert.AreEqual(y, testPiece.YCoord);
 }
Пример #4
0
 public void TestChestPieceConstructorY()
 {
     char excpected = 'K';
     Coordinates newCoordinates = new Coordinates(2, 3);
     int x = newCoordinates.XCoord;
     int y = newCoordinates.YCoord;
     ChessPiece testPiece = new ChessPiece(excpected, newCoordinates);
     Assert.AreEqual(y, testPiece.YCoord);
 }
Пример #5
0
        public void TestConstructor_CreatePawnWithValidParameters()
        {
            ChessPiece chessPiece = new ChessPiece(ChessPieceType.Pawn, 'A', 7, 7);

            Assert.AreEqual(ChessPieceType.Pawn, chessPiece.Type);
            Assert.AreEqual('A', chessPiece.Character);
            Assert.AreEqual(7, chessPiece.Row);
            Assert.AreEqual(7, chessPiece.Col);
        }
Пример #6
0
        public void TestConstructor_CreateKingWithValidParameters()
        {
            ChessPiece chessPiece = new ChessPiece(ChessPieceType.King, 'K', 3, 7);

            Assert.AreEqual(ChessPieceType.King, chessPiece.Type);
            Assert.AreEqual('K', chessPiece.Character);
            Assert.AreEqual(3, chessPiece.Row);
            Assert.AreEqual(7, chessPiece.Col);
        }
Пример #7
0
        public void TestChessPieceClone()
        {
            ChessPiece chessPiece = new ChessPiece(ChessPieceType.Pawn, 'A', 7, 7);

            ChessPiece newChessPiece = (ChessPiece)chessPiece.Clone();

            Assert.IsFalse(object.ReferenceEquals(chessPiece, newChessPiece));
            Assert.IsTrue(chessPiece.Row == newChessPiece.Row);
            Assert.IsTrue(chessPiece.Col == newChessPiece.Col);
            Assert.IsTrue(chessPiece.Character == newChessPiece.Character);
            Assert.IsTrue(chessPiece.Type == newChessPiece.Type);
        }
Пример #8
0
 /// <summary>
 /// Performs a deep copy of the <see cref="ChessPiece"/> object.
 /// </summary>
 /// <returns>A copy of the object being cloned.</returns>
 public object Clone()
 {
     ChessPiece clone = new ChessPiece(this.Type, this.Character, this.Row, this.Col);
     clone.MovesMade = this.MovesMade;
     return clone;
 }
Пример #9
0
        private void UpdatePosition(ChessPiece chessPiece, Move move)
        {
            this.occupied[chessPiece.Row, chessPiece.Col] = false;

            chessPiece.Row += move.DeltaRow;
            chessPiece.Col += move.DeltaCol;
            chessPiece.MovesMade++;

            this.occupied[chessPiece.Row, chessPiece.Col] = true;
        }
Пример #10
0
 public void TestConstructor_WhitespaceCharacterThrowsException()
 {
     ChessPiece chessPiece = new ChessPiece(ChessPieceType.King, ' ', 3, 3);
 }