From 8133f81a6f783980d2fa69d79654edfdecf1f123 Mon Sep 17 00:00:00 2001 From: fdai7600 Date: Wed, 7 Feb 2024 16:51:04 +0100 Subject: [PATCH] Test: added testReadFromFile() for the professor Data --- src/test/java/org/example/ProfessorTest.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/org/example/ProfessorTest.java b/src/test/java/org/example/ProfessorTest.java index ab52603..002f461 100644 --- a/src/test/java/org/example/ProfessorTest.java +++ b/src/test/java/org/example/ProfessorTest.java @@ -1,4 +1,24 @@ package org.example; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.util.List; + +import static org.junit.Assert.assertEquals; + public class ProfessorTest { + + @Test + void testReadFromFile() throws IOException { + Professor professor = new Professor("P1002", "Jane Doe", "Professor"); + professor.writeToFile(); + + List professors = Professor.readFromFile(); + + assertEquals(1, professors.size()); + assertEquals("P1002", professors.get(0).getProfessorID()); + assertEquals("Jane Doe", professors.get(0).getName()); + assertEquals("Professor", professors.get(0).getRole()); + } }