|
@ -2,6 +2,14 @@ import static org.assertj.core.api.Assertions.*; |
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
import org.junit.jupiter.api.Test; |
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
import org.junit.jupiter.params.ParameterizedTest; |
|
|
|
|
|
import org.junit.jupiter.params.provider.Arguments; |
|
|
|
|
|
import org.junit.jupiter.params.provider.MethodSource; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
|
import java.util.Iterator; |
|
|
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
public class PlayerTest { |
|
|
public class PlayerTest { |
|
|
|
|
|
|
|
@ -9,7 +17,7 @@ public class PlayerTest { |
|
|
|
|
|
|
|
|
@BeforeEach |
|
|
@BeforeEach |
|
|
void setup() { |
|
|
void setup() { |
|
|
p = new Player("Rot"); |
|
|
|
|
|
|
|
|
p = new Player("Rot", 40, 43); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Test |
|
|
@Test |
|
@ -39,4 +47,60 @@ public class PlayerTest { |
|
|
assertThat(calculatedResult).describedAs("Starting postion of Figures").isEqualTo(expectedResult); |
|
|
assertThat(calculatedResult).describedAs("Starting postion of Figures").isEqualTo(expectedResult); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ParameterizedTest |
|
|
|
|
|
@MethodSource("FieldStream") |
|
|
|
|
|
void checkGameWin(String testname, Collection<Figure> figures, Collection<Integer> positions, boolean expectedResult) { |
|
|
|
|
|
Iterator<Figure> it = figures.iterator(); |
|
|
|
|
|
Iterator<Integer> it2 = positions.iterator(); |
|
|
|
|
|
for(;it.hasNext();) { |
|
|
|
|
|
it.next().setPosition(it2.next()); |
|
|
|
|
|
} |
|
|
|
|
|
boolean calculatedResult = p.checkGameWin(figures); |
|
|
|
|
|
assertThat(calculatedResult).describedAs("Check Win").isEqualTo(expectedResult); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static Stream<Arguments> FieldStream() { |
|
|
|
|
|
return Stream.of( |
|
|
|
|
|
Arguments.of("No Figure in House", |
|
|
|
|
|
Arrays.asList( |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure()), |
|
|
|
|
|
Arrays.asList(-1, -1, -1, -1), |
|
|
|
|
|
false), |
|
|
|
|
|
Arguments.of("One Figure in House", |
|
|
|
|
|
Arrays.asList( |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure()), |
|
|
|
|
|
Arrays.asList(40, -1, -1, -1), |
|
|
|
|
|
false), |
|
|
|
|
|
Arguments.of("Two Figure in House", |
|
|
|
|
|
Arrays.asList( |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure()), |
|
|
|
|
|
Arrays.asList(40, 41, -1, -1), |
|
|
|
|
|
false), |
|
|
|
|
|
Arguments.of("Three Figure in House", |
|
|
|
|
|
Arrays.asList( |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure()), |
|
|
|
|
|
Arrays.asList(40, 41, 42, -1), |
|
|
|
|
|
false), |
|
|
|
|
|
Arguments.of("Four Figure in House", |
|
|
|
|
|
Arrays.asList( |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure(), |
|
|
|
|
|
new Figure()), |
|
|
|
|
|
Arrays.asList(40, 41, 42, 43), |
|
|
|
|
|
true) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
} |
|
|
} |