mirror of
https://github.com/smyalygames/kahoot-challenge-2025.git
synced 2025-12-03 10:37:54 +01:00
feat: add reading file test
This commit is contained in:
@@ -51,5 +51,26 @@ class ReadFileTest {
|
|||||||
|
|
||||||
assertThrowsExactly(RuntimeException.class, () -> ReadFile.open(nonExistent));
|
assertThrowsExactly(RuntimeException.class, () -> ReadFile.open(nonExistent));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Reading valid file correctly")
|
||||||
|
void openValidFile() throws IOException {
|
||||||
|
String filename = "test.txt";
|
||||||
|
Path path = Files.createFile(tempDir.resolve(filename));
|
||||||
|
|
||||||
|
List<String> emails = new ArrayList<>() {{
|
||||||
|
add("test@test.com");
|
||||||
|
add("person@gmail.com");
|
||||||
|
add("hello@outlook.com");
|
||||||
|
}};
|
||||||
|
|
||||||
|
// Write the emails to the file "test.txt"
|
||||||
|
Files.write(path, emails);
|
||||||
|
|
||||||
|
// Get the output from the function
|
||||||
|
List<String> output = ReadFile.open(path);
|
||||||
|
|
||||||
|
assertEquals(emails, output);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user