2021-12-10 11:02:34 +01:00
|
|
|
package ch.zhaw.catan;
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.Nested;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
|
|
|
|
|
public class SiedlerBoardTest {
|
|
|
|
|
2021-12-10 11:45:57 +01:00
|
|
|
/**
|
|
|
|
* To Test getLongestRoad in SiedlerBoard
|
|
|
|
*/
|
2021-12-10 11:02:34 +01:00
|
|
|
@Nested
|
|
|
|
class LongestRoadTest {
|
|
|
|
|
|
|
|
List<Config.Faction> factionList = Arrays.asList(Config.Faction.values());
|
|
|
|
|
|
|
|
SiedlerBoard board = new SiedlerBoard();
|
|
|
|
|
|
|
|
@BeforeEach
|
|
|
|
public void buildLongestRoad(){
|
|
|
|
board.createFixGameField();
|
|
|
|
board.setEdge(new Point(6, 6), new Point(5, 7), new Road(Config.Faction.BLUE, new Point(6, 6), new Point(5, 7)));
|
|
|
|
board.setEdge(new Point(4, 6), new Point(5, 7), new Road(Config.Faction.BLUE, new Point(4, 6), new Point(5, 7)));
|
|
|
|
board.setEdge(new Point(4, 6), new Point(4, 4), new Road(Config.Faction.BLUE, new Point(4, 6), new Point(4, 4)));
|
|
|
|
board.setEdge(new Point(4, 6), new Point(3, 7), new Road(Config.Faction.BLUE, new Point(4, 6), new Point(3, 7)));
|
|
|
|
board.setEdge(new Point(3, 7), new Point(3, 9), new Road(Config.Faction.BLUE, new Point(3, 7), new Point(3, 9)));
|
|
|
|
board.setEdge(new Point(3, 9), new Point(4, 10), new Road(Config.Faction.BLUE, new Point(3, 9), new Point(4, 10)));
|
|
|
|
board.setEdge(new Point(4, 10), new Point(5, 9), new Road(Config.Faction.BLUE, new Point(4, 10), new Point(5, 9)));
|
|
|
|
board.setCorner(new Point(3, 7), new Settlement(Config.Faction.BLUE, new Point(3, 7)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLongestRoadSimple() {
|
2021-12-10 18:06:52 +01:00
|
|
|
System.out.println(board.toString());
|
2021-12-10 11:02:34 +01:00
|
|
|
|
|
|
|
assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList));
|
2021-12-10 11:20:56 +01:00
|
|
|
assertEquals(6, board.getLongestRoadLength());
|
2021-12-10 11:02:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void testLongestRoadWithInterrupt() {
|
|
|
|
board.setCorner(new Point(4, 10), new Settlement(Config.Faction.RED, new Point(4, 10)));
|
2021-12-10 18:06:52 +01:00
|
|
|
System.out.println(board.toString());
|
2021-12-10 11:02:34 +01:00
|
|
|
|
|
|
|
assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList));
|
2021-12-10 11:20:56 +01:00
|
|
|
assertEquals(5, board.getLongestRoadLength());
|
2021-12-10 11:02:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|