Browse Source

extracted magic numbers

feat-figureMovement
JD 4 years ago
parent
commit
975d2dd3e6
  1. 37
      fh.fd.ci.client/src/test/java/de/fd/fh/FigureFarmerTest.java

37
fh.fd.ci.client/src/test/java/de/fd/fh/FigureFarmerTest.java

@ -6,49 +6,56 @@ import static org.junit.jupiter.api.Assertions.*;
class FigureFarmerTest
{
Figure[] field = new Figure[Figure.fieldLength * Figure.fieldLength];
// weißer Bauer
@Test
void whiteFarmerValidDestination()
{
int src = Figure.fieldLength * 6 + 0;
int dst = Figure.fieldLength * 5 + 0;
Figure f = new FigureFarmer(FigureFarmer.Color.White);
assertTrue(f.moveAllowed(Figure.fieldLength * 6 + 0,
Figure.fieldLength * 5 + 0,
new Figure[Figure.fieldLength * Figure.fieldLength]));
assertTrue(f.moveAllowed(src, dst, field));
}
@Test
void whiteFarmerInvalidDestinationDown() // statt nach "oben" wird nach "unten" gegangen
{
int src = Figure.fieldLength * 6 + 0;
int dst = Figure.fieldLength * 7 + 0;
Figure f = new FigureFarmer(FigureFarmer.Color.White);
assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0,
Figure.fieldLength * 7 + 0,
new Figure[Figure.fieldLength * Figure.fieldLength]));
assertFalse(f.moveAllowed(src, dst, field));
}
@Test
void whiteFarmerInvalidDestinationUp() // mehr als 1 Schritt nach "oben"
{
int src = Figure.fieldLength * 6 + 0;
int dst = Figure.fieldLength * 4 + 0;
Figure f = new FigureFarmer(FigureFarmer.Color.White);
assertFalse(f.moveAllowed(Figure.fieldLength * 6 + 0,
Figure.fieldLength * 4 + 0,
new Figure[Figure.fieldLength * Figure.fieldLength]));
assertFalse(f.moveAllowed(src, dst, field));
}
@Test
void checkMoveWithValidDestinationVar2() // Bauer (w) steht in der Mitte vom Feld und geht 1 nach oben
{
int src = Figure.fieldLength * 4 + 4;
int dst = Figure.fieldLength * 3 + 4;
Figure f = new FigureFarmer(FigureFarmer.Color.White);
assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4,
Figure.fieldLength * 3 + 4,
new Figure[Figure.fieldLength * Figure.fieldLength]));
assertTrue(f.moveAllowed(src, dst, field));
}
@Test
void whiteFarmerInvalidDestinationDownVar2() // Bauer (w) steht in der Mitte vom Feld und geht 1 nach unten
{
int src = Figure.fieldLength * 4 + 4;
int dst = Figure.fieldLength * 5 + 4;
Figure f = new FigureFarmer(FigureFarmer.Color.White);
assertFalse(f.moveAllowed(Figure.fieldLength * 4 + 4,
Figure.fieldLength * 5 + 4,
new Figure[Figure.fieldLength * Figure.fieldLength]));
assertFalse(f.moveAllowed(src, dst, field));
}
}
Loading…
Cancel
Save