-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef5e762
commit 6f6d66d
Showing
7 changed files
with
442 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,4 @@ | ||
/mapValidationTests/ | ||
/halfMapRulesUnitTests/ | ||
/sendHalfMapUnitTests/ | ||
/validateHalfMapUnitTests/ |
65 changes: 65 additions & 0 deletions
65
...laufgabe 3 - Server/MyServer/src/test/java/halfMapRulesUnitTests/HalfMapCastle_tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package halfMapRulesUnitTests; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.function.Executable; | ||
|
||
import MessagesBase.HalfMap; | ||
import MessagesBase.UniqueGameIdentifier; | ||
import exceptions.InvalidMapException; | ||
import rules.IRules; | ||
import rules.RuleHalfMapCastle; | ||
|
||
class HalfMapCastle_tests { | ||
|
||
@Test | ||
void HalfMapCastle_TwoCastles_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'g', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'G', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapCastle(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapCastle_NoCastle_shouldThrow() { | ||
char[][] nodes = { { 'g', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'g', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapCastle(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapCastle_CorrectCastle_shouldNotThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'g', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapCastle(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertDoesNotThrow(testRule); | ||
} | ||
|
||
} |
97 changes: 97 additions & 0 deletions
97
...eilaufgabe 3 - Server/MyServer/src/test/java/halfMapRulesUnitTests/HalfMapEdge_tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package halfMapRulesUnitTests; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.function.Executable; | ||
|
||
import MessagesBase.HalfMap; | ||
import MessagesBase.UniqueGameIdentifier; | ||
import exceptions.InvalidMapException; | ||
import rules.IRules; | ||
import rules.RuleHalfMapEdges; | ||
|
||
class HalfMapEdge_tests { | ||
|
||
@Test | ||
void HalfMapEdge_TooMuchWaterNorth_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'w', 'w', 'g', 'g', 'g' }, { 'g', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'w', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapEdges(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapEdge_TooMuchWaterSouth_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'w', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'w', 'w', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapEdges(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapEdge_TooMuchWaterEast_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'w', 'w', 'g', 'g', 'g', 'w', 'w' }, | ||
{ 'w', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'w' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapEdges(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapEdge_TooMuchWaterWest_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'w', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapEdges(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapEdge_CorrectEdges_shouldNotThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'g', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapEdges(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertDoesNotThrow(testRule); | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
...aufgabe 3 - Server/MyServer/src/test/java/halfMapRulesUnitTests/HalfMapIslands_tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package halfMapRulesUnitTests; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.function.Executable; | ||
|
||
import MessagesBase.HalfMap; | ||
import MessagesBase.UniqueGameIdentifier; | ||
import exceptions.InvalidMapException; | ||
import rules.IRules; | ||
import rules.RuleHalfMapNoIslands; | ||
|
||
class HalfMapIslands_tests { | ||
|
||
@Test | ||
void HalfMapCastle_Island_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'w', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'w', 'g', 'w' }, | ||
{ 'g', 'g', 'w', 'g', 'g', 'g', 'w', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapNoIslands(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapCastle_OtherIsland_shouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'w', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'g', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapNoIslands(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapCastle_NoIsland_shouldNotThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'w', 'w', 'g', 'g', 'g', 'w', 'm' }, | ||
{ 'g', 'g', 'g', 'g', 'g', 'g', 'g', 'g' }, { 'm', 'w', 'w', 'g', 'g', 'm', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapNoIslands(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertDoesNotThrow(testRule); | ||
} | ||
|
||
} |
117 changes: 117 additions & 0 deletions
117
...gabe 3 - Server/MyServer/src/test/java/halfMapRulesUnitTests/HalfMapRightShape_tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
package halfMapRulesUnitTests; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.function.Executable; | ||
|
||
import MessagesBase.HalfMap; | ||
import MessagesBase.UniqueGameIdentifier; | ||
import exceptions.InvalidMapException; | ||
import rules.IRules; | ||
import rules.RuleHalfMapDimensions; | ||
|
||
class HalfMapRightShape_tests { | ||
|
||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' } }; | ||
|
||
@Test | ||
void HalfMapInvalidNumberOfNodes_MissingEntireRow_ShouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapDimensions(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapInvalidNumberOfNodes_MissingOneField_ShouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapDimensions(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapInvalidNumberOfNodes_OneRowTooMany_ShouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'g' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapDimensions(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapInvalidNumberOfNodes_OneFieldTooMany_ShouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'g', 'w', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'w', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapDimensions(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapInvalidNumberOfNodes_OneFieldTooManyInOneRowOneTooLittleInOther_ShouldThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'w' }, { 'g', 'm', 'w', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'm', 'g', 'g', 'g', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapDimensions(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertThrows(InvalidMapException.class, testRule); | ||
} | ||
|
||
@Test | ||
void HalfMapCorrectNumberOfNodes_CorrectMap_ShouldNotThrow() { | ||
char[][] nodes = { { 'G', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' }, | ||
{ 'm', 'w', 'w', 'g', 'g', 'g', 'g', 'g' }, { 'g', 'm', 'w', 'g', 'g', 'g', 'm', 'm' } }; | ||
|
||
HalfMap testMap = Helper.halfMapFromArray(nodes); | ||
|
||
IRules testingRule = new RuleHalfMapDimensions(); | ||
|
||
Executable testRule = () -> { | ||
testingRule.validateNewHalfMap(new UniqueGameIdentifier(), testMap); | ||
}; | ||
|
||
assertDoesNotThrow(testRule); | ||
} | ||
|
||
} |
Oops, something went wrong.