Browse Source

Unittest: integrate TravelEngine and Player

remotes/origin/map
Tanja Herche 2 years ago
parent
commit
9166dc2d18
  1. 18
      src/main/java/org/bitbiome/commands/MapCommand.java
  2. 8
      src/test/java/org/bitbiome/commands/MapCommandTest.java

18
src/main/java/org/bitbiome/commands/MapCommand.java

@ -1,23 +1,21 @@
package org.bitbiome.commands;
import org.bitbiome.classes.TravelEngine;
import org.json.JSONArray;
import java.util.Scanner;
public class MapCommand implements CommandAPI{
@Override
public void performCommand(Scanner scanner, boolean isRunning, String message, TravelEngine travelEngine) {
System.out.println(getMapMessage());
System.out.println(getMapMessage(travelEngine));
}
public static String getMapMessage() {
public static String getMapMessage(TravelEngine travelEngine) {
StringBuilder outputMessage = new StringBuilder();
outputMessage
.append("Map:\n")
.append("Wueste Gruendland Winterland\n\n")
.append("Strand Wald Berge\n\n");
JSONArray locations = travelEngine.getLocationList();
outputMessage
.append("Map:\n")
.append("Wueste Gruenland Winterland\n\n")
.append("Strand Wald Berge\n\n");
return outputMessage.toString();
}
}

8
src/test/java/org/bitbiome/commands/MapCommandTest.java

@ -1,5 +1,7 @@
package org.bitbiome.commands;
import org.bitbiome.classes.TravelEngine;
import org.bitbiome.entities.Player;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ -7,11 +9,13 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class MapCommandTest {
@Test
public void testMapCommand() {
String mapMessage = MapCommand.getMapMessage();
Player Test = new Player("name");
TravelEngine outputtest = new TravelEngine(Test);
String mapMessage = MapCommand.getMapMessage(outputtest);
StringBuilder outputMessage = new StringBuilder();
outputMessage
.append("Map:\n")
.append("Wueste Gruendland Winterland\n\n")
.append("Wueste Gruenland Winterland\n\n")
.append("Strand Wald Berge\n\n");
assertEquals(outputMessage.toString(), mapMessage);
}

Loading…
Cancel
Save