-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskTest.java
More file actions
99 lines (85 loc) · 2.43 KB
/
TaskTest.java
File metadata and controls
99 lines (85 loc) · 2.43 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
package cs3500.pa05.model;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
* Tests the methods in the task class.
*/
class TaskTest {
private Task testTask;
/**
* Sets up fields for testing.
*/
@BeforeEach
public void setUp() {
testTask = new Task("test", "a test task", DayType.SATURDAY, false);
}
/**
* Tests the getter function.
*/
@Test
public void nameProperty() {
assertEquals("test", testTask.nameProperty());
}
/**
* Tests the getter function.
*/
@Test
public void descriptionProperty() {
assertEquals("a test task", testTask.descriptionProperty());
}
/**
* Tests the getter function.
*/
@Test
public void dayOfWeekProperty() {
assertEquals(DayType.SATURDAY, testTask.dayOfWeekProperty());
}
/**
* Tests the getter function.
*/
@Test
public void completeProperty() {
assertFalse(testTask.completeProperty());
}
/**
* Tests the setter function.
*/
@Test
public void setIsComplete() {
testTask.setIsComplete(true);
assertEquals(true, testTask.completeProperty());
}
/**
* Tests the function that converts a task to a string.
*/
@Test
public void taskToString() {
Task task = new Task("n", "", DayType.MONDAY, false);
assertTrue(task.taskToString().contains("Task: n"));
assertTrue(task.taskToString().contains("Day: Monday"));
assertTrue(task.taskToString().contains("Complete: false"));
assertTrue(testTask.taskToString().contains("Task: test"));
assertTrue(testTask.taskToString().contains("Day: Saturday"));
assertTrue(testTask.taskToString().contains("Description: a test task"));
assertTrue(testTask.taskToString().contains("Complete: false"));
}
/**
* Tests the method isUrl
*/
@Test
public void testIsUrl() {
Task task = new Task("n", "", DayType.MONDAY, false);
// a valid URL
String validUrl = "https://example.com";
assertTrue(task.isUrlTask(validUrl));
// an invalid URL
String invalidUrl = "example.com";
assertFalse(task.isUrlTask(invalidUrl));
// an empty string
String emptyString = "";
assertFalse(task.isUrlTask(emptyString));
}
}