Commit 26e06e47 by Paktalin

QueenTest added

parent 43c0cc25
package com.example.paktalin.agilejava_exercises; package com.example.paktalin.agilejava_exercises;
import com.example.paktalin.agilejava_exercises.moves.*; import com.example.paktalin.agilejava_exercises.moves.*;
import com.example.paktalin.agilejava_exercises.pieces.KingTest; import com.example.paktalin.agilejava_exercises.pieces.*;
import com.example.paktalin.agilejava_exercises.pieces.PawnTest;
import junit.framework.TestSuite; import junit.framework.TestSuite;
...@@ -23,6 +22,7 @@ public class AllTests extends TestSuite { ...@@ -23,6 +22,7 @@ public class AllTests extends TestSuite {
suite.addTestSuite(KingTest.class); suite.addTestSuite(KingTest.class);
suite.addTestSuite(PawnTest.class); suite.addTestSuite(PawnTest.class);
suite.addTestSuite(QueenTest.class);
return suite; return suite;
} }
......
...@@ -9,7 +9,7 @@ public class KingTest extends PieceTest { ...@@ -9,7 +9,7 @@ public class KingTest extends PieceTest {
@Override @Override
void setExpectedRepresentation() { void setExpectedRepresentation() {
expectedRepresentation = 'k'; representation = 'k';
} }
@Override @Override
...@@ -19,7 +19,7 @@ public class KingTest extends PieceTest { ...@@ -19,7 +19,7 @@ public class KingTest extends PieceTest {
@Override @Override
void setExpectedStrength() { void setExpectedStrength() {
expectedStrength = 0; strength = 0;
} }
} }
...@@ -9,7 +9,7 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.Black; ...@@ -9,7 +9,7 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.Black;
public class PawnTest extends PieceTest { public class PawnTest extends PieceTest {
@Override @Override
void setExpectedRepresentation() { void setExpectedRepresentation() {
expectedRepresentation = 'p'; representation = 'p';
} }
@Override @Override
...@@ -19,17 +19,17 @@ public class PawnTest extends PieceTest { ...@@ -19,17 +19,17 @@ public class PawnTest extends PieceTest {
@Override @Override
void setExpectedStrength() { void setExpectedStrength() {
expectedStrength = 1; strength = 1;
} }
@Override @Override
public void testStrength() { public void testStrength() {
super.testStrength(); super.testStrength();
expectedStrength = 0.5; strength = 0.5;
board.placePiece(createPiece(Black), "a6"); board.placePiece(createPiece(Black), "a6");
assertEquals(expectedStrength, board.getPieceAtPosition("a6").getStrength()); assertEquals(strength, board.getPieceAtPosition("a6").getStrength());
assertEquals(expectedStrength, board.getPieceAtPosition("a7").getStrength()); assertEquals(strength, board.getPieceAtPosition("a7").getStrength());
} }
} }
...@@ -13,8 +13,8 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.*; ...@@ -13,8 +13,8 @@ import static com.example.paktalin.agilejava_exercises.pieces.Piece.Color.*;
public abstract class PieceTest extends TestCase { public abstract class PieceTest extends TestCase {
char expectedRepresentation; char representation;
double expectedStrength; double strength;
private Position position = Position.create("a7"); private Position position = Position.create("a7");
Board board; Board board;
...@@ -33,20 +33,20 @@ public abstract class PieceTest extends TestCase { ...@@ -33,20 +33,20 @@ public abstract class PieceTest extends TestCase {
Piece blackPiece = createPiece(Black); Piece blackPiece = createPiece(Black);
assertTrue(whitePiece.isWhite()); assertTrue(whitePiece.isWhite());
assertEquals(expectedRepresentation, whitePiece.getRepresentation()); assertEquals(representation, whitePiece.getRepresentation());
assertTrue(blackPiece.isBlack()); assertTrue(blackPiece.isBlack());
assertEquals(getBlackRepresentation(), blackPiece.getRepresentation()); assertEquals(getBlackRepresentation(), blackPiece.getRepresentation());
} }
private char getBlackRepresentation() { private char getBlackRepresentation() {
return Character.toUpperCase(expectedRepresentation); return Character.toUpperCase(representation);
} }
public void testStrength() { public void testStrength() {
board = Board.createEmpty(); board = Board.createEmpty();
board.placePiece(createPiece(Black), position); 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