Browse Source

Unittest: MapCommand

remotes/origin/map
Tanja Herche 2 years ago
parent
commit
9c5dbc57d7
  1. 1
      src/main/java/org/bitbiome/commands/CommandListener.java
  2. 23
      src/main/java/org/bitbiome/commands/MapCommand.java
  3. 18
      src/test/java/org/bitbiome/commands/MapCommandTest.java

1
src/main/java/org/bitbiome/commands/CommandListener.java

@ -18,6 +18,7 @@ public class CommandListener {
commands.put("quit", new QuitCommand()); commands.put("quit", new QuitCommand());
commands.put("location", new LocationCommand()); commands.put("location", new LocationCommand());
commands.put("travel", new TravelCommand()); commands.put("travel", new TravelCommand());
commands.put("map", new MapCommand());
} }
public HashMap<String, CommandAPI> returnCommands() { public HashMap<String, CommandAPI> returnCommands() {

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

@ -0,0 +1,23 @@
package org.bitbiome.commands;
import org.bitbiome.classes.TravelEngine;
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());
}
public static String getMapMessage() {
StringBuilder outputMessage = new StringBuilder();
outputMessage
.append("Map:\n")
.append("Wueste Gruendland Winterland\n\n")
.append("Strand Wald Berge\n\n");
return outputMessage.toString();
}
}

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

@ -0,0 +1,18 @@
package org.bitbiome.commands;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class MapCommandTest {
@Test
public void testMapCommand() {
String mapMessage = MapCommand.getMapMessage();
StringBuilder outputMessage = new StringBuilder();
outputMessage
.append("Map:\n")
.append("Wueste Gruendland Winterland\n\n")
.append("Strand Wald Berge\n\n");
assertEquals(outputMessage.toString(), mapMessage);
}
}
Loading…
Cancel
Save