|
@ -57,4 +57,58 @@ class MapTest { |
|
|
assertThat(expectedMiddle).isEqualTo(middle); |
|
|
assertThat(expectedMiddle).isEqualTo(middle); |
|
|
assertThat(expectedBottomRight).isEqualTo(bottomRight); |
|
|
assertThat(expectedBottomRight).isEqualTo(bottomRight); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void Map_getPath_returnCorrectPathSimple() { |
|
|
|
|
|
// arrange |
|
|
|
|
|
String[] mapTest = { |
|
|
|
|
|
"wwwww", |
|
|
|
|
|
"w...w", |
|
|
|
|
|
"w.w.w", |
|
|
|
|
|
"w.w.w", |
|
|
|
|
|
"wwwww" |
|
|
|
|
|
}; |
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
|
|
|
gameManager.map = new Map(mapTest, gameManager); |
|
|
|
|
|
|
|
|
|
|
|
Vector2 from = new Vector2(1, 1); |
|
|
|
|
|
Vector2 to = new Vector2(3, 1); |
|
|
|
|
|
|
|
|
|
|
|
String expectedPath = "uurrdd"; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
|
|
|
|
|
|
String path = gameManager.map.FindPath(from, to); |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
assertThat(path).isEqualTo(expectedPath); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
void Map_getPath_returnCorrectPathComplex() { |
|
|
|
|
|
// arrange |
|
|
|
|
|
String[] mapTest = { |
|
|
|
|
|
"wwwwwwwww", |
|
|
|
|
|
"w.....w.w", |
|
|
|
|
|
"w.www.w.w", |
|
|
|
|
|
"w.w...w.w", |
|
|
|
|
|
"w.w.www.w", |
|
|
|
|
|
"w.w.....w", |
|
|
|
|
|
"wwwwwwwww" |
|
|
|
|
|
}; |
|
|
|
|
|
GameManager gameManager = new GameManager(); |
|
|
|
|
|
gameManager.map = new Map(mapTest, gameManager); |
|
|
|
|
|
|
|
|
|
|
|
Vector2 from = new Vector2(4, 3); |
|
|
|
|
|
Vector2 to = new Vector2(1, 1); |
|
|
|
|
|
|
|
|
|
|
|
String expectedPath = "ruulllldddd"; |
|
|
|
|
|
|
|
|
|
|
|
// act |
|
|
|
|
|
|
|
|
|
|
|
String path = gameManager.map.FindPath(from, to); |
|
|
|
|
|
|
|
|
|
|
|
// assert |
|
|
|
|
|
assertThat(path).isEqualTo(expectedPath); |
|
|
|
|
|
} |
|
|
} |
|
|
} |