UNIT TESTINH IS HELL

This commit is contained in:
iryupnik 2020-05-27 13:49:26 +02:00
parent 107a57b710
commit 7c959b93c7
33 changed files with 83 additions and 83 deletions

Binary file not shown.

View File

@ -6,9 +6,18 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter:5.7.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.7.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.1.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.2.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.7.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-params:5.7.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-engine:5.7.0-M1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-engine:1.7.0-M1" level="project" />
</component>
</module>

View File

@ -18,4 +18,12 @@
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -41,7 +41,7 @@ public class Game extends JFrame {
battle = new WindowOfBattle(this);
//tohle spustí na začátku menu
// add(menu);
add(menu);
//tohle spustí na začátku hru
// add(freeMove);
@ -52,7 +52,7 @@ public class Game extends JFrame {
// battle.startBattle();
//Tohle spustí na začátku tileset overview
new LevelEditor();
//new LevelEditor();
setDefaultCloseOperation(EXIT_ON_CLOSE);
setUndecorated(true);

View File

@ -30,7 +30,7 @@ public class ImageCell {
try {
mapBackground = new int[WindowOfFreeMove.CANVAS_WIDTH][WindowOfFreeMove.CANVAS_HEIGHT];
mapForeground = new int[WindowOfFreeMove.CANVAS_WIDTH][WindowOfFreeMove.CANVAS_HEIGHT];
File mapFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + name + "-tileset.txt");
File mapFile = new File("src/main/resources/maps/" + WindowOfFreeMove.getCHAPTER() + "/" + name + "-tileset.txt");
Scanner scanner = new Scanner(mapFile);
int j = 0;
while (scanner.hasNextLine()) {
@ -96,7 +96,7 @@ public class ImageCell {
public void imageObjectset(String file) {
try {
File objectFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + file + "-objectset.txt");
File objectFile = new File("src/main/resources/maps/" + WindowOfFreeMove.getCHAPTER() + "/" + file + "-objectset.txt");
Scanner scanner = new Scanner(objectFile);
int j = 0;
while (scanner.hasNextLine()) {

View File

@ -58,7 +58,7 @@ public class Map {
public static Map loadMapFromFile(String name, WindowOfFreeMove window) {
try {
File file = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + name + ".txt");
File file = new File("src/main/resources/maps/" + WindowOfFreeMove.getCHAPTER() + "/" + name + ".txt");
scanner = new Scanner(file);
String firstLine = scanner.nextLine();
String[] size = firstLine.split(" ");
@ -139,7 +139,7 @@ public class Map {
public void linkMaps(Map map, WindowOfFreeMove window) {
try {
File dialogFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + map.getName() + ".txt");
File dialogFile = new File("src/main/resources/maps/" + WindowOfFreeMove.getCHAPTER() + "/" + map.getName() + ".txt");
scanner = new Scanner(dialogFile);
String firstLine = scanner.nextLine();
String[] size = firstLine.split(" ");

View File

@ -73,7 +73,7 @@ public class LoadManager {
while (scanner.hasNextLine()) {
String[] mapName = scanner.nextLine().split(" ");
if (mapName[0].equals("<" + WindowOfFreeMove.CHAPTER + ">")) {
if (mapName[0].equals("<" + WindowOfFreeMove.getCHAPTER() + ">")) {
Map map = Map.loadMapFromFile(mapName[1], window);
if (mapName[1].equals("tutorial")) map.getPerson().setImagePerson("tutorialpers", rec);
else map.getPerson().setImagePerson("main", rec);
@ -96,7 +96,7 @@ public class LoadManager {
Scanner scanner = new Scanner(npcsFile);
while (scanner.hasNextLine()) {
String[] npcName = scanner.nextLine().split(" ");
if (npcName[0].equals("<" + WindowOfFreeMove.CHAPTER + ">")) {
if (npcName[0].equals("<" + WindowOfFreeMove.getCHAPTER() + ">")) {
File npcFile = new File("src/main/resources/characters/" + npcName[1] + ".txt");
Scanner sc = new Scanner(npcFile);
String[] position = sc.nextLine().split(" ");

View File

@ -21,7 +21,7 @@ public class SoundManager {
public void loadSoundMap(String file) {
try {
File mapFile = new File("src/main/resources/maps/" + WindowOfFreeMove.CHAPTER + "/" + file + "-tileset.txt");
File mapFile = new File("src/main/resources/maps/" + WindowOfFreeMove.getCHAPTER() + "/" + file + "-tileset.txt");
Scanner scanner = new Scanner(mapFile);
soundMap = new HashMap<>();
while (scanner.hasNextLine()) {

View File

@ -35,7 +35,15 @@ public class WindowOfFreeMove extends JLayeredPane {
private static final int KEY_ESCAPE = 27;
public static int CHAPTER = 0;
public static String getCHAPTER() {
return CHAPTER;
}
public static void setCHAPTER(String CHAPTER) {
WindowOfFreeMove.CHAPTER = CHAPTER;
}
private static String CHAPTER = "0";
private JFrame game;
private Canvas canvas;
@ -190,7 +198,7 @@ public class WindowOfFreeMove extends JLayeredPane {
}
public void loadNextChapter() {
CHAPTER++;
CHAPTER = String.valueOf(Integer.parseInt(CHAPTER) + 1);
isReadyToPaint = false;
mapLinkedList = new LinkedList<>();
mapManager = new MapManager(mapLinkedList, canvas, this);

View File

@ -1,65 +0,0 @@
<map>
<mapName>tutorial</mapName>
<events>
<trigger>
<x>11</x>
<y>6</y>
<active>false</active>
</trigger>
</events>
</map>
<map>
<mapName>openspace</mapName>
<events>
<trigger>
<x>6</x>
<y>4</y>
<active>true</active>
</trigger>
<trigger>
<x>14</x>
<y>16</y>
<active>false</active>
</trigger>
<chest>
<x>15</x>
<y>7</y>
<active>true</active>
</chest>
</events>
</map>
<map>
<mapName>office</mapName>
<events>
<trigger>
<x>4</x>
<y>2</y>
<active>false</active>
</trigger>
<chest>
<x>1</x>
<y>9</y>
<active>true</active>
</chest>
</events>
</map>
<map>
<mapName>boss</mapName>
<events>
<trigger>
<x>4</x>
<y>18</y>
<active>true</active>
</trigger>
</events>
</map>
<map>
<mapName>treasure</mapName>
<events>
<trigger>
<x>6</x>
<y>1</y>
<active>true</active>
</trigger>
</events>
</map>

View File

@ -1,6 +0,0 @@
<location>
<map>openspace</map>
<x>8</x>
<y>16</y>
<direction>3</direction>
</location>

View File

@ -1 +0,0 @@
TODO: Village

View File

@ -0,0 +1,47 @@
package ruscz.game.gameOfProd.Scripts;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import ruscz.game.gameOfProd.Map.Map;
import ruscz.game.gameOfProd.Windows.WindowOfFreeMove;
import javax.swing.*;
import java.util.stream.Stream;
public class PathFinderTest {
public static Stream<Arguments> argumentsStream(){
return Stream.of(
Arguments.of(1,1,1,1)
// Arguments.of(),
// Arguments.of(),
// Arguments.of(),
// Arguments.of()
);
}
@ParameterizedTest
@MethodSource("argumentsStream")
public void getWayWithCollision_usingMap6ForTestOfPathFinding_rightPositionOfNpc(int startX, int startY, int endX, int endY) {
//Arrange
WindowOfFreeMove freeMove;
//Act
freeMove = new WindowOfFreeMove(new JFrame());
freeMove.setVisible(false);
WindowOfFreeMove.setCHAPTER("999");
freeMove.start(true);
freeMove.setMapManager(Map.findMapByName("m6",freeMove));
//Assert
}
}