@Test public void testSendCommand() { String re = "result"; String comm = "command"; TerminalMock2 t1 = new TerminalMock2(null); TerminalMock2 t2 = new TerminalMock2(re); TerminalMock2 t3 = new TerminalMock2(null); Console console = new Console(); console.registerRover(t1); console.registerRover(t2); console.registerRover(t3); assertEquals(re, console.sendCommand("command")); assertEquals(comm, t1.command); assertEquals(comm, t2.command); assertNull(t3.command); }
private void setUserInput(String inputs[]) { List<String> inputList = Arrays.asList(inputs); when(console.getUserCommand()).thenAnswer(AdditionalAnswers.returnsElementsOf(inputList)); }