You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package Application;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.PrintStream;
import static org.junit.jupiter.api.Assertions.*;
class AppTest {
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); private final ByteArrayInputStream inContent = new ByteArrayInputStream("1\n2\nq\n".getBytes());
App app; Cli cli;
@BeforeEach void setUp() { cli = new Cli(new PrintStream(outContent), inContent); cli.setClearConsoleActive(false); app = new App(cli); }
@AfterEach void tearDown() { }
//inContent has the 'q' at the end, to terminated the loop and set isRunning to false
@Test void stop() { ByteArrayInputStream input = new ByteArrayInputStream("1\n2\nq\n".getBytes()); cli = new Cli(new PrintStream(outContent), input); cli.setClearConsoleActive(false); app = new App(cli); app.start(); assertFalse(app.isRunning()); }
@Test void selectMenuItem() { assertNull(app.getCurrentGame()); app.selectMenuItem("1"); assertNull(app.getCurrentGame()); app.selectMenuItem("2"); assertNotNull(app.getCurrentGame()); } }
|