-
Notifications
You must be signed in to change notification settings - Fork 0
/
CourseListTest.java
83 lines (73 loc) · 2.66 KB
/
CourseListTest.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.UUID;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class CourseListTest {
private CourseList course = CourseList.getInstance();
private ArrayList<Course> courseList = course.getAllCourses();
@BeforeEach
public void setup() {
courseList.clear();
ArrayList<String> answers = new ArrayList<String>();
answers.add("A");
answers.add("B");
answers.add("C");
answers.add("D");
Question question = new Question("First question", answers, 1);
Question question2 = new Question("Second question", answers, 2);
ArrayList<Question> questions = new ArrayList<Question>();
ArrayList<Question> questions2 = new ArrayList<Question>();
questions.add(question);
questions2.add(question2);
Quiz quiz = new Quiz(questions);
Quiz quiz2 = new Quiz(questions2);
Lesson lesson = new Lesson("First Content", "First Lesson", quiz);
Lesson lesson2 = new Lesson("Second Content", "First Lesson", quiz2);
ArrayList<Lesson> lessons = new ArrayList<Lesson>();
ArrayList<Lesson> lessons2 = new ArrayList<Lesson>();
lessons.add(lesson);
lessons2.add(lesson2);
Module module = new Module("First Module title", lessons);
Module module2 = new Module("Second Module title", lessons2);
ArrayList<Module> modules = new ArrayList<Module>();
ArrayList<Module> modules2 = new ArrayList<Module>();
modules.add(module);
modules2.add(module2);
UUID author = UUID.randomUUID();
courseList.add(new Course(author,"Test1", "The first test", "First syllabus", Difficulty.EASY, Language.PYTHON, modules));
courseList.add(new Course(author,"Test2", "The second test", "Second syllabus", Difficulty.MEDIUM, Language.JAVASCRIPT, modules2));
DataWriter.saveUsers();
}
@AfterEach
public void tearDown() {
CourseList.getInstance().getAllCourses().clear();
DataWriter.saveUsers();
}
@Test
void testHaveCourseValidFirstItem() {
boolean hasTest = course.haveCourse("Test1");
assertTrue(hasTest);
}
@Test
void testHaveCourseValidLastItem() {
boolean hasTest = course.haveCourse("Test2");
assertTrue(hasTest);
}
@Test
void testHaveCourseInValid() {
boolean hasTest = course.haveCourse("Test4");
assertFalse(hasTest);
}
@Test
void testHaveCourseEmpty() {
boolean hasEmpty = course.haveCourse("");
assertFalse(hasEmpty);
}
@Test
void testHaveCourse() {
boolean hasNull = course.haveCourse(null);
assertFalse(hasNull);
}
}