Add command tests

This commit is contained in:
Arne Keller 2020-02-28 11:59:40 +01:00
parent f240ecf5f0
commit fffc21a73e
3 changed files with 17 additions and 0 deletions

6
commands1_input.txt Normal file
View File

@ -0,0 +1,6 @@
list-buildings
list-resources
list-buildings I can build
list-resources I can buy
reset
reset the game

6
commands1_output.txt Normal file
View File

@ -0,0 +1,6 @@
EMPTY
EMPTY
Error, invalid list-buildings argument: none expected
Error, invalid list-resources argument: none expected
OK
Error, invalid reset argument: none expected

View File

@ -13,6 +13,11 @@ class MainTest {
cmpInOut("game1_input.txt", "game1_output.txt"); cmpInOut("game1_input.txt", "game1_output.txt");
} }
@Test
void commands1() throws IOException {
cmpInOut("commands1_input.txt", "commands1_output.txt");
}
private void cmpInOut(String in, String out) throws IOException { private void cmpInOut(String in, String out) throws IOException {
System.setIn(new ByteArrayInputStream(readFile(in))); System.setIn(new ByteArrayInputStream(readFile(in)));
ByteArrayOutputStream output = new ByteArrayOutputStream(); ByteArrayOutputStream output = new ByteArrayOutputStream();