75 lines
1.6 KiB
Java
75 lines
1.6 KiB
Java
package letzplay.ganttproject;
|
|
|
|
import letzplay.core.Output;
|
|
import letzplay.ganttproject.GanttGameLoop;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
import static letzplay.ganttproject.GanttProjectTriggers.*;
|
|
|
|
class GanttGameLoopTest {
|
|
|
|
@Test
|
|
public void testLoop() {
|
|
GanttGameLoop loop = GanttGameLoop.getGameLoop();
|
|
|
|
loop.init();
|
|
loop.update();
|
|
loop.output();
|
|
}
|
|
|
|
@Test
|
|
public void testTrigger() {
|
|
GanttGameLoop loop = GanttGameLoop.getGameLoop();
|
|
Output out;
|
|
|
|
System.out.println("Iteration 0");
|
|
loop.init();
|
|
loop.update();
|
|
loop.output();
|
|
|
|
System.out.println("Iteration 1");
|
|
loop.input(res+add);
|
|
loop.update();
|
|
loop.output();
|
|
out = loop.output();
|
|
|
|
assertEquals(out.lvl, 1);
|
|
assertEquals(out.quests.size(), 2);
|
|
}
|
|
|
|
@Test
|
|
public void testSaveAndLoad(){
|
|
GanttGameLoop loop = GanttGameLoop.getGameLoop();
|
|
|
|
loop.init();
|
|
loop.input("test1");
|
|
loop.input("test2");
|
|
loop.update();
|
|
|
|
List<String> before = loop.game.getState();
|
|
|
|
try {
|
|
loop.save();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
loop.init();
|
|
try {
|
|
loop.load();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
} catch (ClassNotFoundException e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
List<String> after = loop.game.getState();
|
|
|
|
assertEquals(before,after);
|
|
}
|
|
|
|
} |