-
Notifications
You must be signed in to change notification settings - Fork 0
/
CourseListTester.java
61 lines (48 loc) · 1.8 KB
/
CourseListTester.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import static org.junit.jupiter.api.Assertions.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Date;
public class CourseListTester {
private CourseList courses = CourseList.getInstance();
private ArrayList<Course> courseList = courses.getCourses();
@BeforeEach
public void setup() {
courseList.clear();
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
String dateOfBirth = "11/01/2011";
Date dob = new Date();
try {
dob = dateFormat.parse(dateOfBirth);
} catch (Exception e) {
e.printStackTrace();
}
Course tempCourse = new Course("mikes course", new Author("mike", "cluver", "flowerlover9", "newpassword",
dob, "8654756543", "mickeymousefan12"));
courseList.add(tempCourse);
DataWriter.writeCourses(courseList);
}
@AfterEach
public void tearDown() {
CourseList.getInstance().getCourses().clear();
DataWriter.writeCourses(courseList);
}
@Test
public void testAddCourse() {
assertEquals("mikes course", CourseList.getInstance().getCourseByName("mikes course"));
}
@Test
public void testGetCourseByName() {
assertEquals("mikes course", CourseList.getInstance().getCourseByName("mikes course").getCourseName());
}
@Test
public void testSearchCoursesByName() {
assertEquals("mikes course", CourseList.getInstance().SearchCoursesByName("mikes").get(0).getCourseName());
}
@Test
public void testSave() {
assertEquals("mikes course", CourseList.getInstance().getCourseByName("mikes course"));
}
}