package de.gurkenlabs.litiengine;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class GameTest {
  private static boolean wasCalled;

  @BeforeEach
  public void prepare() {
    wasCalled = false;
  }

  @AfterEach
  public void cleanup() {
    final File configFile = new File(Game.getConfiguration().getFileName());
    if (configFile.exists()) {
      configFile.delete();
    }
  }

  @Test
  public void testGameInitialization() {
    Game.init(Game.COMMADLINE_ARG_NOGUI);

    assertNotNull(Game.getRenderLoop());
    assertNotNull(Game.getLoop());
    assertNotNull(Game.getCamera());
    assertNotNull(Game.getScreenManager());
    assertNotNull(Game.getPhysicsEngine());
    assertNotNull(Game.getRenderEngine());
  }

  @Test
  public void testInitializedListeners() {
    Game.addGameListener(new GameAdapter() {
      @Override
      public void initialized(String... args) {
        wasCalled = true;
      }
    });

    Game.init(Game.COMMADLINE_ARG_NOGUI);

    assertTrue(wasCalled);
  }

  @Test
  public void testStartedListeners() {
    Game.addGameListener(new GameAdapter() {
      @Override
      public void started() {
        wasCalled = true;
      }
    });

    Game.init(Game.COMMADLINE_ARG_NOGUI);
    Game.start();
    assertTrue(wasCalled);
  }
}

@@ -24,24 +24,84 @@
 itiengine;%0A%0A
+import static org.junit.jupiter.api.Assertions.assertFalse;%0A
 import stati
@@ -150,16 +150,16 @@
 otNull;%0A
-
 import s
@@ -376,112 +376,8 @@
 st %7B
-%0A  private static boolean wasCalled;%0A%0A  @BeforeEach%0A  public void prepare() %7B%0A    wasCalled = false;%0A  %7D
 %0A%0A  
@@ -943,32 +943,70 @@
 edListeners() %7B%0A
+    final boolean wasCalled = false;%0A%0A
     Game.addGame
@@ -1259,24 +1259,62 @@
 steners() %7B%0A
+    final boolean wasCalled = false;%0A%0A
     Game.add
@@ -1427,32 +1427,32 @@
      %7D%0A    %7D);%0A%0A
-
     Game.init(Ga
@@ -1477,16 +1477,44 @@
 NOGUI);%0A
+    assertFalse(wasCalled);%0A
     Game

Improve the unit tests with closures