forked from nus-cs2103-AY2425S1/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
1 parent
14dc131
commit 53f8d02
Showing
6 changed files
with
110 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"java.configuration.updateBuildConfiguration": "interactive" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import nathanbot.tasks.Deadline; | ||
|
||
public class DeadlineTest { | ||
|
||
@Test | ||
public void testToString() { | ||
LocalDateTime dateTime = LocalDateTime.of(2023, 10, 5, 14, 30); | ||
Deadline deadline = new Deadline("Submit assignment", dateTime); | ||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd MMM yyyy hh:mma"); | ||
String expected = "[D][ ] Submit assignment (by: " + dateTime.format(dateTimeFormatter) + ")"; | ||
assertEquals(expected, 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,20 @@ | ||
import java.time.LocalDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import nathanbot.tasks.Event; | ||
|
||
public class EventTest { | ||
|
||
@Test | ||
public void testToString() { | ||
LocalDateTime startTime = LocalDateTime.of(2023, 10, 5, 14, 30); | ||
LocalDateTime endTime = LocalDateTime.of(2024, 10, 5, 14, 30); | ||
Event event = new Event("Submit assignment", startTime, endTime); | ||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("dd MMM yyyy hh:mma"); | ||
String expected = "[E][ ] Submit assignment (from: " + startTime.format(dateTimeFormatter) + " to: " + endTime.format(dateTimeFormatter) + ")"; | ||
assertEquals(expected, 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,53 @@ | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.when; | ||
|
||
import nathanbot.storage.Storage; | ||
import nathanbot.tasks.Task; | ||
import nathanbot.tasks.TaskList; | ||
|
||
public class TaskListTest { | ||
// built with Copilot's assistance | ||
private Storage storage; | ||
private TaskList taskList; | ||
private Task task1; | ||
private Task task2; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
storage = mock(Storage.class); | ||
task1 = mock(Task.class); | ||
task2 = mock(Task.class); | ||
|
||
when(storage.loadTasksFromFile()).thenReturn(new ArrayList<>(Arrays.asList(task1, task2))); | ||
|
||
taskList = new TaskList(storage); | ||
} | ||
|
||
@Test | ||
public void testConstructorLoadsTasks() { | ||
assertEquals(2, taskList.listLength()); | ||
} | ||
|
||
@Test | ||
public void testAddTask() { | ||
Task newTask = mock(Task.class); | ||
taskList.addTask(newTask); | ||
|
||
assertEquals(3, taskList.listLength()); | ||
} | ||
|
||
@Test | ||
public void testToString() { | ||
when(task1.toString()).thenReturn("Task 1"); | ||
when(task2.toString()).thenReturn("Task 2"); | ||
|
||
String expected = "1. Task 1\n2. Task 2\n"; | ||
assertEquals(expected, taskList.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,14 @@ | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import nathanbot.tasks.ToDo; | ||
|
||
public class ToDoTest { | ||
|
||
@Test | ||
public void testToString() { | ||
ToDo toDo = new ToDo("Submit assignment"); | ||
String expected = "[T][ ] Submit assignment"; | ||
assertEquals(expected, toDo.toString()); | ||
} | ||
} |