added comments and cleaned code
This commit is contained in:
parent
d9b9ea79a8
commit
63f4c07685
@ -1,15 +0,0 @@
|
|||||||
<map>
|
|
||||||
<mapName>m1</mapName>
|
|
||||||
<events>
|
|
||||||
</events>
|
|
||||||
</map>
|
|
||||||
<map>
|
|
||||||
<mapName>m6</mapName>
|
|
||||||
<events>
|
|
||||||
<trigger>
|
|
||||||
<x>11</x>
|
|
||||||
<y>11</y>
|
|
||||||
<active>true</active>
|
|
||||||
</trigger>
|
|
||||||
</events>
|
|
||||||
</map>
|
|
||||||
@ -13,6 +13,9 @@ import static ruscz.game.gameOfProd.Windows.WindowOfFreeMove.sleep;
|
|||||||
|
|
||||||
public class BattleTest {
|
public class BattleTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Procesní test, který simuluje průběh celé bitvy - silný hrdina vs. slabí nepřátelé
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void startBattle_battleWithAMightHero_winOfHero(){
|
public void startBattle_battleWithAMightHero_winOfHero(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -55,6 +58,9 @@ public class BattleTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Procesní test, který simuluje průběh celé bitvy - slabý hrdina vs. silní nepřátelé
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void startBattle_battleWithAMightEnemy_winOfEnemy(){
|
public void startBattle_battleWithAMightEnemy_winOfEnemy(){
|
||||||
//Arrange
|
//Arrange
|
||||||
|
|||||||
@ -11,6 +11,9 @@ public class InventoryManagerTest {
|
|||||||
InventoryManager.flushInventory();
|
InventoryManager.flushInventory();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje přidání itemu do inventáře hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void addItem_addItemInInventory_successfulAdd(){
|
public void addItem_addItemInInventory_successfulAdd(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -31,6 +34,9 @@ public class InventoryManagerTest {
|
|||||||
Assertions.assertTrue(InventoryManager.getInventory().contains(i3));
|
Assertions.assertTrue(InventoryManager.getInventory().contains(i3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje odebrání itemu z inventáře hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void removeItem_removeItemFromInventory_successfulRemove(){
|
public void removeItem_removeItemFromInventory_successfulRemove(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -53,6 +59,9 @@ public class InventoryManagerTest {
|
|||||||
Assertions.assertTrue(InventoryManager.getInventory().contains(i3));
|
Assertions.assertTrue(InventoryManager.getInventory().contains(i3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje přidání itemu, který už v inventáři je, do inventáře hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void addItem_increaseMultiplicityOfItem_successfulIncreasing(){
|
public void addItem_increaseMultiplicityOfItem_successfulIncreasing(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -72,6 +81,9 @@ public class InventoryManagerTest {
|
|||||||
Assertions.assertEquals(12, InventoryManager.getInventory().getFirst().getMultiplicity());
|
Assertions.assertEquals(12, InventoryManager.getInventory().getFirst().getMultiplicity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje odebrání itemu s násobností z inventáře hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void removeItem_decreaseMultiplicityOfItem_successfulReduce(){
|
public void removeItem_decreaseMultiplicityOfItem_successfulReduce(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -93,6 +105,9 @@ public class InventoryManagerTest {
|
|||||||
Assertions.assertEquals(11, InventoryManager.getInventory().getFirst().getMultiplicity());
|
Assertions.assertEquals(11, InventoryManager.getInventory().getFirst().getMultiplicity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje odebrání itemu, který v inventáři není, z inventáře hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void removeItem_tryDecreaseNonExistedItemOrDecreaseTooMuch_unsuccessfulReduce(){
|
public void removeItem_tryDecreaseNonExistedItemOrDecreaseTooMuch_unsuccessfulReduce(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -111,6 +126,9 @@ public class InventoryManagerTest {
|
|||||||
Assertions.assertEquals(10, InventoryManager.getInventory().getFirst().getMultiplicity());
|
Assertions.assertEquals(10, InventoryManager.getInventory().getFirst().getMultiplicity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje hledání itemu v inventáři hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findItemByName_searchingExistedItem_Item(){
|
public void findItemByName_searchingExistedItem_Item(){
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -125,6 +143,9 @@ public class InventoryManagerTest {
|
|||||||
Assertions.assertEquals(i1, InventoryManager.findItemByName(i1.getName()));
|
Assertions.assertEquals(i1, InventoryManager.findItemByName(i1.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje hledání itemu, který není v inventíři hrdiny
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void findItemByName_trySearchingExistedItem_null(){
|
public void findItemByName_trySearchingExistedItem_null(){
|
||||||
//Arrange
|
//Arrange
|
||||||
|
|||||||
@ -29,6 +29,10 @@ public class LevelEditorTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param tilesets je pole názvů jednotlivých obrázků s tilesety
|
||||||
|
* JUnit test, který simuluje vygenerování tilesetu z jednoho nebo více obrázků
|
||||||
|
*/
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("argumentsStream")
|
@MethodSource("argumentsStream")
|
||||||
public void generateOverview_generateTilesetsFromImages_CorrectlyGeneratedTilesets(String[] tilesets) {
|
public void generateOverview_generateTilesetsFromImages_CorrectlyGeneratedTilesets(String[] tilesets) {
|
||||||
@ -61,6 +65,12 @@ public class LevelEditorTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param name název mapy
|
||||||
|
* @param width šířka mapy
|
||||||
|
* @param height výska mapy
|
||||||
|
* JUnit test, který simuluje vytvoření mapy pro editaci v level editoru
|
||||||
|
*/
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("argumentsStream2")
|
@MethodSource("argumentsStream2")
|
||||||
public void createMap_createNewMapForLevelEditor_CorrectlyCreatedMap(String name, int width, int height) {
|
public void createMap_createNewMapForLevelEditor_CorrectlyCreatedMap(String name, int width, int height) {
|
||||||
@ -88,6 +98,10 @@ public class LevelEditorTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws IOException kvůli porovnávání obsahu souborů a Scanneru
|
||||||
|
* Procesní test, který simuluje, vytvoření mapy v level editoru a její následné uložení do souborů
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void saveMap_saveMapToFiles_CorrectlySavedMap() throws IOException {
|
public void saveMap_saveMapToFiles_CorrectlySavedMap() throws IOException {
|
||||||
//Arrange
|
//Arrange
|
||||||
|
|||||||
@ -18,6 +18,9 @@ import java.util.stream.Stream;
|
|||||||
|
|
||||||
public class MapTest {
|
public class MapTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JUnit test, který simuluje načtení mapy ze souboru do matice buněk
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void loadMapFromFile_parseMapFileToMapArray_mapArrayParsedCorrectly() {
|
public void loadMapFromFile_parseMapFileToMapArray_mapArrayParsedCorrectly() {
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -51,6 +54,11 @@ public class MapTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param cell referenční buňka
|
||||||
|
* @param cellText text k parsování
|
||||||
|
* JUnit test, který simuluje naparsování textu na konkrétní buňku s vlastnostmi
|
||||||
|
*/
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("argumentsStream")
|
@MethodSource("argumentsStream")
|
||||||
public void loadMapFromFile_parseStringToCorrectObject_MapObjectParsedCorrectly(Cell cell, String cellText) {
|
public void loadMapFromFile_parseStringToCorrectObject_MapObjectParsedCorrectly(Cell cell, String cellText) {
|
||||||
|
|||||||
@ -39,6 +39,14 @@ public class PathFinderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param startX počáteční hodnota X
|
||||||
|
* @param startY počáteční hodnota Y
|
||||||
|
* @param endX koncová hodnota X
|
||||||
|
* @param endY koncová hodnota Y
|
||||||
|
* @param isPossible boolean určující zda je cesta proveditelná
|
||||||
|
* Procesní test, který simuluje automatický pohyb NPC po mapě za pomoci A* aloritmu na hledání nejkratší cesty
|
||||||
|
*/
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("argumentsStream")
|
@MethodSource("argumentsStream")
|
||||||
public void getWayWithCollision_usingMap6ForTestOfPathFinding_rightPositionOfNpc(int startX, int startY, int endX, int endY, boolean isPossible) {
|
public void getWayWithCollision_usingMap6ForTestOfPathFinding_rightPositionOfNpc(int startX, int startY, int endX, int endY, boolean isPossible) {
|
||||||
|
|||||||
@ -65,6 +65,12 @@ public class WindowOfFreeMoveTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param directions pole jednotlivých vstupů
|
||||||
|
* @param xPath předpokládaná ušlá vzdálenost na ose X
|
||||||
|
* @param yPath předpokládaná ušlá vzdálenost na ose Y
|
||||||
|
* Procesní test, který simuluje pohyb hrdiny po mapě, pomocí inputu od uživatele
|
||||||
|
*/
|
||||||
@ParameterizedTest
|
@ParameterizedTest
|
||||||
@MethodSource("argumentsStream")
|
@MethodSource("argumentsStream")
|
||||||
public void move_moveCharacterOnMap_CharacterChangesPositionWithCollisionDetection(int[] directions, int xPath, int yPath) {
|
public void move_moveCharacterOnMap_CharacterChangesPositionWithCollisionDetection(int[] directions, int xPath, int yPath) {
|
||||||
@ -99,6 +105,9 @@ public class WindowOfFreeMoveTest {
|
|||||||
timer.stop();
|
timer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Procesní test, který simuluje přechod hrdiny na jinou matu pomocí MOVETO buňky
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void moveToMap_CharacterMovesToDifferentMap_CharacterIsOnCorrectMap() {
|
public void moveToMap_CharacterMovesToDifferentMap_CharacterIsOnCorrectMap() {
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -151,6 +160,9 @@ public class WindowOfFreeMoveTest {
|
|||||||
Assertions.assertEquals("m6", freeMove.getMapManager().getActualMap().getName());
|
Assertions.assertEquals("m6", freeMove.getMapManager().getActualMap().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Procesní test, který simuluje interakci hrdiny s TRIGGER buňkou a průchod spuštěnou událostí
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void startEvent_CharacterEntersEventThenGoesThroughEventThenExitsEvent_CorrectCharacterResponses() {
|
public void startEvent_CharacterEntersEventThenGoesThroughEventThenExitsEvent_CorrectCharacterResponses() {
|
||||||
//Arrange
|
//Arrange
|
||||||
@ -231,6 +243,9 @@ public class WindowOfFreeMoveTest {
|
|||||||
Assertions.assertEquals(triggerCell.getY(), person.getY());
|
Assertions.assertEquals(triggerCell.getY(), person.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Procesní test, který simuluje interakci s TRIGGER buňkou, přechod na jinou mapu a následné uložení postupu ve hře
|
||||||
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void saveGame_CharacterInteractsWithTriggerCellThenMovesToDifferentMapThenGameIsSaved_CorrectlySavedProgress() {
|
public void saveGame_CharacterInteractsWithTriggerCellThenMovesToDifferentMapThenGameIsSaved_CorrectlySavedProgress() {
|
||||||
//Assert
|
//Assert
|
||||||
@ -284,7 +299,8 @@ public class WindowOfFreeMoveTest {
|
|||||||
|
|
||||||
//Act
|
//Act
|
||||||
person = freeMove.getMapManager().getActualMap().getPerson();
|
person = freeMove.getMapManager().getActualMap().getPerson();
|
||||||
int[] personCoords = new int[]{person.getX(), person.getY(), person.getDirectionSight()};
|
String[] personCoords = new String[]{freeMove.getMapManager().getActualMap().getName(), String.valueOf(person.getX()),
|
||||||
|
String.valueOf(person.getY()), String.valueOf(person.getDirectionSight())};
|
||||||
boolean triggerIsActive = testMap.findTriggerByXY(11, 11).getActive();
|
boolean triggerIsActive = testMap.findTriggerByXY(11, 11).getActive();
|
||||||
saveManager = new SaveManager(freeMove.getMapManager());
|
saveManager = new SaveManager(freeMove.getMapManager());
|
||||||
saveManager.saveGame();
|
saveManager.saveGame();
|
||||||
@ -294,15 +310,16 @@ public class WindowOfFreeMoveTest {
|
|||||||
freeMove = new WindowOfFreeMove(game);
|
freeMove = new WindowOfFreeMove(game);
|
||||||
game.add(freeMove);
|
game.add(freeMove);
|
||||||
WindowOfFreeMove.setCHAPTER("999");
|
WindowOfFreeMove.setCHAPTER("999");
|
||||||
freeMove.setCanvasSize(new int[]{50, 50});
|
WindowOfFreeMove.setCanvasSize(new int[]{50, 50});
|
||||||
freeMove.start(false);
|
freeMove.start(false);
|
||||||
|
|
||||||
sleep(1000);
|
sleep(1000);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
Assertions.assertEquals(personCoords[0], freeMove.getMapManager().getActualMap().getPerson().getX());
|
Assertions.assertEquals(personCoords[0], freeMove.getMapManager().getActualMap().getName());
|
||||||
Assertions.assertEquals(personCoords[1], freeMove.getMapManager().getActualMap().getPerson().getY());
|
Assertions.assertEquals(personCoords[1], String.valueOf(freeMove.getMapManager().getActualMap().getPerson().getX()));
|
||||||
Assertions.assertEquals(personCoords[2], freeMove.getMapManager().getActualMap().getPerson().getDirectionSight());
|
Assertions.assertEquals(personCoords[2], String.valueOf(freeMove.getMapManager().getActualMap().getPerson().getY()));
|
||||||
|
Assertions.assertEquals(personCoords[3], String.valueOf(freeMove.getMapManager().getActualMap().getPerson().getDirectionSight()));
|
||||||
Assertions.assertEquals(triggerIsActive, Map.findMapByName("m6", freeMove).findTriggerByXY(11, 11).getActive());
|
Assertions.assertEquals(triggerIsActive, Map.findMapByName("m6", freeMove).findTriggerByXY(11, 11).getActive());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user