From 37318e912c6c02d41fca5255c44eb3ecfbd4c367 Mon Sep 17 00:00:00 2001 From: Lorenz Hohmann Date: Thu, 16 Dec 2021 15:34:16 +0100 Subject: [PATCH] matchfield: added getState() to get state from one field --- .../fleetstorm/matchfield/MatchfieldCreation.java | 4 ++++ .../matchfield/MatchfieldCreationTest.java | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java b/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java index ed3da8c..6ad69b3 100644 --- a/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java +++ b/src/main/java/de/tims/fleetstorm/matchfield/MatchfieldCreation.java @@ -25,4 +25,8 @@ public class MatchfieldCreation { return this.matchfield.length * this.matchfield[0].length; } + public int getState(int x, int y) { + return 1; + } + } diff --git a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java index 79b0047..37c1ede 100644 --- a/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java +++ b/src/test/java/de/tims/fleetstorm/matchfield/MatchfieldCreationTest.java @@ -32,4 +32,18 @@ class MatchfieldCreationTest { static Stream testMatchfieldSize() { return Stream.of(Arguments.of("field size 10x10", 10, 100), Arguments.of("field size 15x15", 15, 225)); } + + @ParameterizedTest(name = "matchfield change field is correct") + @MethodSource("testMatchfieldGetFieldState") + void testMatchfieldGetCorrectState(String testName, int x, int y, int expectedResult) { + MatchfieldCreation matchfield = new MatchfieldCreation(10); + matchfield.createMatchfield(); + + int calcResult = matchfield.getState(x, y); + assertThat(calcResult).describedAs(testName).isEqualTo(expectedResult); + } + + static Stream testMatchfieldGetFieldState() { + return Stream.of(Arguments.of("field x:0 y:0 has initial state", 0, 0, 1)); + } }