From bf512128f78bcbb1b10ab8692f13229a152a8f50 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 10 Dec 2021 09:12:16 +0100 Subject: [PATCH] update testLongestRoad --- test/ch/zhaw/catan/SiedlerGameTest.java | 56 +++++++++++++++++-------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/test/ch/zhaw/catan/SiedlerGameTest.java b/test/ch/zhaw/catan/SiedlerGameTest.java index 18ab609..b9f2606 100644 --- a/test/ch/zhaw/catan/SiedlerGameTest.java +++ b/test/ch/zhaw/catan/SiedlerGameTest.java @@ -31,27 +31,47 @@ public class SiedlerGameTest { @DisplayName("Positive test cases") class PositiveTestcases { - /** - * To Test getLongestRoad in SiedlerBoard - * - */ - @Test - public void testLongestRoad() { + @Nested + class LongestRoadTest { + /** + * To Test getLongestRoad in SiedlerBoard + */ + List factionList = Arrays.asList(Config.Faction.values()); SiedlerBoard board = new SiedlerBoard(); - 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))); - assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); - assertEquals(6,board.getLongestRoadLenth()); - //todo prüfen ob länge Stimmt. + + + @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() { + System.out.println(board.getTextView()); + + assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); + assertEquals(6, board.getLongestRoadLenth()); + } + + @Test + public void testLongestRoadWithInterrupt() { + board.setCorner(new Point(4, 10), new Settlement(Config.Faction.RED, new Point(4, 10))); + System.out.println(board.getTextView()); + + assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); + assertEquals(5, board.getLongestRoadLenth()); + } } /**