diff --git a/src/main/java/project/app/warzone/Utilities/Maps/Jtest.map b/src/main/java/project/app/warzone/Utilities/Maps/Jtest.map new file mode 100644 index 0000000..b74ef81 --- /dev/null +++ b/src/main/java/project/app/warzone/Utilities/Maps/Jtest.map @@ -0,0 +1,17 @@ +[continents] +Pink 5 +Blue 3 + +[countries] +1 Rock 1 +2 Roll 1 +3 Greek 2 +4 Lamp 2 +5 Shade 2 + +[borders] +1 2 +2 1 3 +3 2 +4 5 +5 4 diff --git a/src/main/java/project/app/warzone/Utilities/Maps/Jtest2.map b/src/main/java/project/app/warzone/Utilities/Maps/Jtest2.map new file mode 100644 index 0000000..244d9d5 --- /dev/null +++ b/src/main/java/project/app/warzone/Utilities/Maps/Jtest2.map @@ -0,0 +1,22 @@ +[continents] +Pink 5 +Blue 3 +Red 1 + +[countries] +1 Rock 1 +2 Roll 1 +3 Greek 2 +4 Lamp 2 +5 Shade 2 +6 Paper 3 +7 Star 3 + +[borders] +1 2 +2 1 3 +3 2 +4 5 +5 4 +6 5 +7 1 diff --git a/src/main/java/project/app/warzone/Utilities/Maps/SimpsonsTest.map b/src/main/java/project/app/warzone/Utilities/Maps/SimpsonsTest.map new file mode 100644 index 0000000..0c7f210 --- /dev/null +++ b/src/main/java/project/app/warzone/Utilities/Maps/SimpsonsTest.map @@ -0,0 +1,51 @@ +; map: Simpsons.map +; map made with the map maker +; yura.net Risk 1.0.9.2 +; The Simpsons Map by Bestel + +[files] +pic Simpsons_pic.png +map Simpsons_map.gif +crd Simpsons.cards + +[continents] +Rez_de_Chausse 5 #cc0000 +1er_tage 5 white + +[countries] +1 Entry 1 105 237 +2 Garage 1 206 312 +3 Laundry 1 230 219 +4 Rumpus_room 1 233 144 +5 Kitchen 1 149 109 +6 Dining_room 1 159 200 +7 Living_room 1 51 217 +8 TV_room 1 56 131 +9 Bart's_room 2 354 226 +10 Lisa's_room 2 505 233 +11 Homer_&_Marge's_room 2 610 221 +12 Homer_&_Marge's_closet 2 628 95 +13 Homer_et_Marge's_bathroom 2 543 76 +14 Maggie's_room 2 473 79 +15 Maggie's_closet 2 407 96 +16 Bathroom 2 347 104 +17 Hall 2 448 138 + +[borders] +1 7 6 17 +2 3 +3 2 4 +4 3 5 +5 4 6 8 +6 1 5 +7 1 8 +8 5 7 +9 17 +10 17 +11 17 12 13 +12 11 +13 11 +14 17 15 +15 14 +16 17 +17 1 9 10 11 14 16 diff --git a/src/test/java/project/app/warzone/Features/MapFeaturesTest.java b/src/test/java/project/app/warzone/Features/MapFeaturesTest.java new file mode 100644 index 0000000..48edcdc --- /dev/null +++ b/src/test/java/project/app/warzone/Features/MapFeaturesTest.java @@ -0,0 +1,67 @@ +package project.app.warzone.Features; +import static org.junit.Assert.assertEquals; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.stringtemplate.v4.compiler.STParser.mapExpr_return; +import project.app.warzone.Features.MapFeatures; + + +import project.app.warzone.Model.GameEngine; +import project.app.warzone.Model.Map; + + +public class MapFeaturesTest { + + public MapFeatures mapFeatures; + + @BeforeEach + public void setUp(){ + this.mapFeatures = new MapFeatures(); + } + + @Test + public void testValidateEntireGraphWithValidMap() { + String mapFileName = System.getProperty("user.dir") + "/src/main/java/project/app/warzone/Utilities/Maps/" + "Castle.map"; + Map l_map = this.mapFeatures.readMap(mapFileName); + GameEngine l_gameEngine = new GameEngine(l_map); + boolean l_isMapValid = this.mapFeatures.validateEntireGraph(l_gameEngine); + assertTrue(l_isMapValid); + } + + @Test + public void testValidateEntireGraphWithInvalidMap() { + String mapFileName = System.getProperty("user.dir") + "/src/main/java/project/app/warzone/Utilities/Maps/" + "Jtest2.map"; + Map l_map = this.mapFeatures.readMap(mapFileName); + GameEngine l_gameEngine = new GameEngine(l_map); + boolean l_isMapValid = this.mapFeatures.validateEntireGraph(l_gameEngine); + assertFalse(l_isMapValid); + } + + @Test + public void testValidateValidContinent() { + String mapFileName = System.getProperty("user.dir") + "/src/main/java/project/app/warzone/Utilities/Maps/" + "Castle.map"; + Map l_map = this.mapFeatures.readMap(mapFileName); + GameEngine l_gameEngine = new GameEngine(l_map); + //boolean l_isContinentValid = this.mapFeatures.validateContinent(l_gameEngine, l_map.getListOfContinents().get(0)); + //assertTrue(l_isContinentValid); + } + + @Test + public void testValidateInvalidContinent() { + String mapFileName = System.getProperty("user.dir") + "/src/main/java/project/app/warzone/Utilities/Maps/" + "Jtest2.map"; + Map l_map = this.mapFeatures.readMap(mapFileName); + GameEngine l_gameEngine = new GameEngine(l_map); + //boolean l_isContinentValid = this.mapFeatures.validateContinent(l_gameEngine, l_map.getListOfContinents().get(2)); + //assertFalse(l_isContinentValid); + } +}