Commit 26e06e47 by Paktalin

QueenTest added

parent 43c0cc25
package com.example.paktalin.agilejava_exercises;
import com.example.paktalin.agilejava_exercises.moves.*;
import com.example.paktalin.agilejava_exercises.pieces.KingTest;
import com.example.paktalin.agilejava_exercises.pieces.PawnTest;
import com.example.paktalin.agilejava_exercises.pieces.*;
import junit.framework.TestSuite;
......@@ -23,6 +22,7 @@ public class AllTests extends TestSuite {
suite.addTestSuite(KingTest.class);
suite.addTestSuite(PawnTest.class);
suite.addTestSuite(QueenTest.class);
return suite;
}
......
......@@ -9,7 +9,7 @@ public class KingTest extends PieceTest {
@Override
void setExpectedRepresentation() {
expectedRepresentation = 'k';
representation = 'k';
}
@Override
......@@ -19,7 +19,7 @@ public class KingTest extends PieceTest {
@Override
void setExpectedStrength() {
expectedStrength = 0;
strength = 0;
}
}
......@@ -9,7 +9,7 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.Black;
public class PawnTest extends PieceTest {
@Override
void setExpectedRepresentation() {
expectedRepresentation = 'p';
representation = 'p';
}
@Override
......@@ -19,17 +19,17 @@ public class PawnTest extends PieceTest {
@Override
void setExpectedStrength() {
expectedStrength = 1;
strength = 1;
}
@Override
public void testStrength() {
super.testStrength();
expectedStrength = 0.5;
strength = 0.5;
board.placePiece(createPiece(Black), "a6");
assertEquals(expectedStrength, board.getPieceAtPosition("a6").getStrength());
assertEquals(expectedStrength, board.getPieceAtPosition("a7").getStrength());
assertEquals(strength, board.getPieceAtPosition("a6").getStrength());
assertEquals(strength, board.getPieceAtPosition("a7").getStrength());
}
}
......@@ -13,8 +13,8 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.*;
public abstract class PieceTest extends TestCase {
char expectedRepresentation;
double expectedStrength;
char representation;
double strength;
private Position position = Position.create("a7");
Board board;
......@@ -33,20 +33,20 @@ public abstract class PieceTest extends TestCase {
Piece blackPiece = createPiece(Black);
assertTrue(whitePiece.isWhite());
assertEquals(expectedRepresentation, whitePiece.getRepresentation());
assertEquals(representation, whitePiece.getRepresentation());
assertTrue(blackPiece.isBlack());
assertEquals(getBlackRepresentation(), blackPiece.getRepresentation());
}
private char getBlackRepresentation() {
return Character.toUpperCase(expectedRepresentation);
return Character.toUpperCase(representation);
}
public void testStrength() {
board = Board.createEmpty();
board.placePiece(createPiece(Black), position);
assertEquals(expectedStrength, board.getPieceAtPosition(position).getStrength());
assertEquals(strength, board.getPieceAtPosition(position).getStrength());
}
}
package com.example.paktalin.agilejava_exercises.pieces;
/**
* Created by Paktalin on 01/06/2018.
*/
public class QueenTest extends PieceTest {
@Override
void setExpectedRepresentation() {
representation = 'q';
}
@Override
Piece createPiece(Piece.Color color) {
return new Queen(color);
}
@Override
void setExpectedStrength() {
strength = 9;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment