Commit ae6d61e4 authored by 9731050's avatar 9731050

3th

parent 1ab10fd8
...@@ -12,6 +12,7 @@ public class Department { ...@@ -12,6 +12,7 @@ public class Department {
this.name=name; this.name=name;
students=new ArrayList<Student>(); students=new ArrayList<Student>();
courses=new ArrayList<Course>(); courses=new ArrayList<Course>();
professors=new ArrayList<Professor>();
} }
public String getName(){ public String getName(){
......
...@@ -7,36 +7,54 @@ import com.university.Student; ...@@ -7,36 +7,54 @@ import com.university.Student;
import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
public class DepartmentTest { public class DepartmentTest {
static Department department; static Department department;
static Student student; static Student student,s2;
static Course course; static Course course,c2;
static Professor professor; static Professor professor,p2;
static ArrayList<Course>courses;
static ArrayList<Professor>professors;
static ArrayList<Student>students;
@BeforeAll @BeforeAll
public static void creatStudent() public static void creatStudent()
{ {
courses=new ArrayList<>();
professors=new ArrayList<>();
students=new ArrayList<>();
department=new Department("abc"); department=new Department("abc");
professor=new Professor(department,"kz"); professor=new Professor(department,"kz");
course=new Course("123","math",department,professor,3); course=new Course("123","math",department,professor,3);
student=new Student("ali","1234","abc",department); student=new Student("ali","1234","abc",department);
s2=new Student("Mohammad","124","b",new Department("aa"));
department.addCourse(course); department.addCourse(course);
department.addProfessor(professor); department.addProfessor(professor);
department.addStudent(student); department.addStudent(student);
department.addStudent(s2);
for(int i=0;i<department.getStudents().size();i++)
students.add(department.getStudents().get(i));
for(int j=0;j<department.getProfessors().size();j++)
professors.add(department.getProfessors().get(j));
for(int z=0;z<department.getCourses().size();z++)
courses.add(department.getCourses().get(z));
} }
@Test @Test
public void Test(){ public void Test(){
assertEquals("abc",department.getName()); assertEquals("abc",department.getName());
assertEquals(professor,department.getProfessors().get(0)); assertEquals(professors,department.getProfessors());
assertEquals(course,department.getCourses().get(0)); assertEquals(courses,department.getCourses());
assertEquals(student,department.getStudents().get(0)); assertEquals(students,department.getStudents());
department.removeCourse(course); department.removeCourse(course);
courses.remove(course);
department.removeProfessor(professor); department.removeProfessor(professor);
professors.remove(professor);
department.removeStudent(student); department.removeStudent(student);
assertEquals(0,department.getProfessors().get(0)); students.remove(student);
assertEquals(0,department.getCourses().get(0)); assertEquals(professors,department.getProfessors());
assertEquals(0,department.getStudents().get(0)); assertEquals(courses,department.getCourses());
assertEquals(students,department.getStudents());
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment