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.
Update tests to follow code standards
- Loading branch information
Showing
3 changed files
with
59 additions
and
22 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 |
---|---|---|
@@ -1,4 +1 @@ | ||
T | 1 | read book | ||
E | 1 | appointment | 22/8/2024 1700 - 22/8/2024 1900 | ||
T | 0 | sleep | ||
D | 0 | quiz | 25/9/2024 1000 | ||
E | 0 | floor event | 25/9/2024 1400 - 25/9/2024 1900 |
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,47 +1,71 @@ | ||
package nimbus.command; | ||
|
||
|
||
import nimbus.ui.TaskList; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import nimbus.exception.WrongInputException; | ||
import nimbus.ui.TaskList; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
/** | ||
* Tests method in add Command | ||
*/ | ||
public class AddCommandTest { | ||
|
||
/** | ||
* Tests if todoTask can be added correctly | ||
*/ | ||
@Test | ||
public void testAddCommandTodoTask() { | ||
public void testAddCommand_todoTask() { | ||
String userInput = "todo Tutorial"; | ||
TaskList taskList = new TaskList(); | ||
new AddCommand(userInput, taskList).execute(); | ||
assertEquals("[T][ ] Tutorial", | ||
taskList.getTaskList().get(0).toString().trim()); | ||
} | ||
|
||
/** | ||
* Tests if deadlineTask can be added correctly | ||
*/ | ||
@Test | ||
public void testAddCommandDeadlineTask() { | ||
public void testAddCommand_deadlineTask() { | ||
String userInput = "deadline Tutorial /by 22/8/2024 1200"; | ||
TaskList taskList = new TaskList(); | ||
new AddCommand(userInput, taskList).execute(); | ||
assertEquals("[D][ ] Tutorial (by: Aug 22 2024 12:00 pm)", | ||
assertEquals("[D][ ] Tutorial (by: Aug 22 2024 12:00 pm)", | ||
taskList.getTaskList().get(0).toString().trim()); | ||
} | ||
|
||
/** | ||
* Tests if eventTask can be added correctly | ||
*/ | ||
@Test | ||
public void testAddCommandEventTask() { | ||
public void testAddCommand_eventTask() { | ||
String userInput = "event appointment /from 22/8/2024 1200 /to 22/8/2024 1400"; | ||
TaskList taskList = new TaskList(); | ||
new AddCommand(userInput, taskList).execute(); | ||
assertEquals("[E][ ] appointment (from: Aug 22 2024 12:00 pm to: Aug 22 2024 2:00 pm)", | ||
taskList.getTaskList().get(0).toString().trim()); | ||
} | ||
|
||
/** | ||
* Tests if exception thrown if wrong description | ||
*/ | ||
@Test | ||
public void testAddCommandWrongDescription() { | ||
public void testAddCommand_wrongDescription() { | ||
String userInput = "random"; | ||
TaskList taskList = new TaskList(); | ||
new AddCommand(userInput, taskList).execute(); | ||
|
||
WrongInputException exception = assertThrows(WrongInputException.class, () -> { | ||
new AddCommand(userInput, taskList).execute(); | ||
}); | ||
|
||
String expectedMessage = "Sorry Nimbus don't understand what you are saying QwQ \n" | ||
+ "Try using todo, deadline or event!"; | ||
assertTrue(exception.getMessage().contains(expectedMessage)); | ||
|
||
assertEquals(0, taskList.getTaskList().size()); | ||
} | ||
} |
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