diff --git a/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java b/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java index f735fd9..c101ca2 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java +++ b/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java @@ -2,8 +2,20 @@ package de.tims.fleetstorm.matchfield; public class MatchfieldCreation { - public int[][] createMatchfield() { - return new int[][] {}; + public int[][] createMatchfield(int size) { + int[][] matchfield = new int[size][size]; + + for (int i = 0; i < size; i++) { + for (int j = 0; j < size; j++) { + matchfield[i][j] = 1; + } + } + + return matchfield; + } + + public int getSize() { + return 10; } } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java index 65e47fa..e285b46 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java @@ -1,8 +1,14 @@ package de.tims.fleetstorm.matchfield; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertNotNull; +import java.util.stream.Stream; + 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; class MatchfieldCreationTest { @@ -10,7 +16,19 @@ class MatchfieldCreationTest { @Test void testMatchfieldCreateNotEmpty() { - int[][] calcResult = matchfield.createMatchfield(); + int[][] calcResult = matchfield.createMatchfield(0); assertNotNull(calcResult); } + + @ParameterizedTest(name = "matchfield creation has correct size") + @MethodSource("testMatchfieldSize") + void testMatchfieldCreationHasCorrectSize(String testName, int size, int expectedResult) { + matchfield.createMatchfield(size); + int calcResult = matchfield.getSize(); + assertThat(calcResult).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream testMatchfieldSize() { + return Stream.of(Arguments.of("field size 10x10", 10, 10)); + } }