|
|
@ -0,0 +1,41 @@ |
|
|
|
package game; |
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
import java.io.FileWriter; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import org.junit.jupiter.api.BeforeEach; |
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
class runGameTest { |
|
|
|
|
|
|
|
@BeforeEach |
|
|
|
void setUp() throws Exception { |
|
|
|
} |
|
|
|
|
|
|
|
@Test |
|
|
|
public void testCountFileLinesWithThreeLines() { |
|
|
|
//arrange |
|
|
|
int numLines = 0; |
|
|
|
File file; |
|
|
|
try { |
|
|
|
file = File.createTempFile("temp", ".txt"); |
|
|
|
FileWriter writer = new FileWriter(file); |
|
|
|
writer.write("Zeile 1\n"); |
|
|
|
writer.write("Zeile 2\n"); |
|
|
|
writer.write("Zeile 3\n"); |
|
|
|
writer.close(); |
|
|
|
//act |
|
|
|
numLines = runGame.CountFileLines(file.getAbsolutePath()); |
|
|
|
} catch (IOException e) { |
|
|
|
// TODO Auto-generated catch block |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//assert |
|
|
|
assertEquals(4, numLines); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |