forked from nus-cs2103-AY2324S2/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
171 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
D | 1 | read | Dec-02-2023 18:00 | ||
E | 0 | read | Dec-02-2023 18:00 - Dec-03-2023 18:00 | ||
E | 1 | read | Dec-02-2023 18:00 - Dec-03-2023 18:00 | ||
D | 0 | read | Dec-02-2023 18:00 | ||
E | 0 | read | Dec-02-2023 18:00 - Dec-03-2023 08:30 | ||
T | 0 | eat | ||
E | 0 | eat | Dec-02-2023 18:00 - Dec-03-2023 17:00 | ||
D | 0 | eat | Dec-02-2023 18:00 | ||
D | 0 | eat | Dec-02-2023 18:00 | ||
T | 1 | read |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package actions; | ||
import org.junit.jupiter.api.Test; | ||
import task.Deadline; | ||
import task.Event; | ||
import task.Task; | ||
import task.Todo; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.ArrayList; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
public class TaskListTest { | ||
@Test | ||
public void listTest() { | ||
ArrayList<Task> tasks = new ArrayList<>(); | ||
Todo todo = new Todo("read", false); | ||
tasks.add(todo); | ||
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
Deadline deadline = new Deadline("read book", false, by ); | ||
tasks.add(deadline); | ||
|
||
LocalDateTime from = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
LocalDateTime to = LocalDateTime.parse("3/12/2023 1800", formatter); | ||
Event event = new Event("school", false, from, to ); | ||
tasks.add(event); | ||
|
||
TaskList taskList = new TaskList(tasks); | ||
assertEquals(tasks, taskList.getTasks()); | ||
|
||
} | ||
|
||
@Test | ||
public void addTest() { | ||
ArrayList<Task> tasks = new ArrayList<>(); | ||
ArrayList<Task> newTasks = new ArrayList<>(); | ||
|
||
Todo todo = new Todo("read", false); | ||
tasks.add(todo); | ||
newTasks.add(todo); | ||
|
||
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
Deadline deadline = new Deadline("read book", false, by ); | ||
tasks.add(deadline); | ||
newTasks.add(deadline); | ||
|
||
LocalDateTime from = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
LocalDateTime to = LocalDateTime.parse("3/12/2023 1800", formatter); | ||
Event event = new Event("school", false, from, to ); | ||
tasks.add(event); | ||
newTasks.add(event); | ||
|
||
Todo newTodo = new Todo("eat", false); | ||
newTasks.add(newTodo); | ||
|
||
TaskList taskList = new TaskList(tasks); | ||
taskList.addTask(newTodo); | ||
assertEquals(newTasks, tasks); | ||
} | ||
|
||
|
||
@Test | ||
public void deleteTest() { | ||
ArrayList<Task> tasks = new ArrayList<>(); | ||
ArrayList<Task> newTasks = new ArrayList<>(); | ||
|
||
Todo todo = new Todo("read", false); | ||
tasks.add(todo); | ||
newTasks.add(todo); | ||
|
||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
Deadline deadline = new Deadline("read book", false, by ); | ||
tasks.add(deadline); | ||
newTasks.add(deadline); | ||
|
||
LocalDateTime from = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
LocalDateTime to = LocalDateTime.parse("3/12/2023 1800", formatter); | ||
Event event = new Event("school", false, from, to ); | ||
tasks.add(event); | ||
|
||
TaskList taskList = new TaskList(tasks); | ||
taskList.deleteTask(2); | ||
assertEquals(newTasks, tasks); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package tasks; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import task.Deadline; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class DeadlineTest { | ||
@Test | ||
public void newDeadlineTask() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
Deadline deadline = new Deadline("read book", false, by ); | ||
assertEquals("[D] [ ] read book (by:Dec 02 2023 18:00)", deadline.toString()); | ||
} | ||
|
||
@Test | ||
public void markEvent() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime by = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
Deadline deadline = new Deadline("read book", false, by ); | ||
deadline.markAsDone(); | ||
assertEquals("[D] [X] read book (by:Dec 02 2023 18:00)", deadline.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package tasks; | ||
import org.junit.jupiter.api.Test; | ||
import task.Event; | ||
import task.Event; | ||
|
||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
public class EventTest { | ||
@Test | ||
public void newEventTask() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime from = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
LocalDateTime to = LocalDateTime.parse("3/12/2023 1800", formatter); | ||
Event event = new Event("school", false, from, to ); | ||
assertEquals("[E] [ ] school (from:Dec 02 2023 18:00 to:Dec 03 2023 18:00)", event.toString()); | ||
} | ||
|
||
@Test | ||
public void markEvent() { | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/M/yyyy HHmm"); | ||
LocalDateTime from = LocalDateTime.parse("2/12/2023 1800", formatter); | ||
LocalDateTime to = LocalDateTime.parse("3/12/2023 1800", formatter); | ||
Event event = new Event("school", false, from, to ); | ||
event.markAsDone(); | ||
assertEquals("[E] [X] school (from:Dec 02 2023 18:00 to:Dec 03 2023 18:00)", event.toString()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package tasks; | ||
import org.junit.jupiter.api.Test; | ||
import task.Todo; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
public class TodoTest { | ||
@Test | ||
public void newTodoTask() { | ||
Todo todo = new Todo("read", false); | ||
assertEquals("[T] [ ] read", todo.toString()); | ||
} | ||
|
||
@Test | ||
public void markTodo() { | ||
Todo todo = new Todo("read", false); | ||
todo.markAsDone(); | ||
assertEquals("[T] [X] read", todo.toString()); | ||
} | ||
} |