|
|
package de.fd.fh;
import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource;
import static org.junit.jupiter.api.Assertions.*;
class FigureFarmerTest { Figure[] field = new Figure[Figure.fieldLength * Figure.fieldLength];
// weißer Bauer
@ParameterizedTest // row (src), col (src), row (dst), col (dst)
@CsvSource({ "6, 0, 5, 0", // a2 -> a3
"4, 4, 3, 4" // e4 -> e5
}) void whiteFarmerValidDestination(int srcRow, int srcCol, int dstRow, int dstCol) { int src = Figure.fieldLength * srcRow + srcCol; int dst = Figure.fieldLength * dstRow + dstCol;
Figure f = new FigureFarmer(FigureFarmer.Color.White); assertTrue(f.moveAllowed(src, dst, field)); }
// weißer Bauer
@ParameterizedTest // row (src), col (src), row (dst), col (dst)
@CsvSource({ "6, 0, 7, 0", // a2 -> a1
"4, 4, 5, 4" // e4 -> e3
}) void whiteFarmerInvalidDestinationDown(int srcRow, int srcCol, int dstRow, int dstCol) // statt nach "oben" wird nach "unten" gegangen
{ int src = Figure.fieldLength * srcRow + srcCol; int dst = Figure.fieldLength * dstRow + dstCol;
Figure f = new FigureFarmer(FigureFarmer.Color.White); 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(src, dst, field)); } }
|