|
@ -0,0 +1,28 @@ |
|
|
|
|
|
package org.example; |
|
|
|
|
|
|
|
|
|
|
|
import org.junit.jupiter.api.Test; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
|
|
import java.nio.file.Files; |
|
|
|
|
|
import java.nio.file.Path; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.*; |
|
|
|
|
|
class StudentTest { |
|
|
|
|
|
|
|
|
|
|
|
@org.junit.jupiter.api.Test |
|
|
|
|
|
void writeToFile() throws IOException { |
|
|
|
|
|
Student student = new Student("Sebastian", "S1001", "Student") ; |
|
|
|
|
|
|
|
|
|
|
|
String filename = "testStudentData.txt"; |
|
|
|
|
|
|
|
|
|
|
|
student.writeToFile(student, filename); |
|
|
|
|
|
|
|
|
|
|
|
Path path = Path.of(filename); |
|
|
|
|
|
String content = Files.readString(path); |
|
|
|
|
|
assertEquals("Sebastian\nS1001\nStudent", content); |
|
|
|
|
|
|
|
|
|
|
|
Files.delete(path); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |