forked from nus-cs2103-AY2324S1/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
3 changed files
with
128 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,59 @@ | ||
package duke; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import duke.Parser; | ||
import duke.command.AddCommand; | ||
import duke.command.DeleteCommand; | ||
import duke.command.ExitCommand; | ||
import duke.command.ListCommand; | ||
import duke.command.MarkCommand; | ||
import duke.command.UnmarkCommand; | ||
import duke.command.Command; | ||
import duke.exception.InvalidArgumentException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class ParserTest { | ||
|
||
@Test | ||
public void testParseListCommand() throws InvalidArgumentException { | ||
Command command = Parser.parse("list"); | ||
assertTrue(command instanceof ListCommand); | ||
} | ||
|
||
@Test | ||
public void testParseDeleteCommand() throws InvalidArgumentException { | ||
Command command = Parser.parse("delete 1"); | ||
assertTrue(command instanceof DeleteCommand); | ||
} | ||
|
||
@Test | ||
public void testParseMarkCommand() throws InvalidArgumentException { | ||
Command command = Parser.parse("mark 1"); | ||
assertTrue(command instanceof MarkCommand); | ||
} | ||
|
||
@Test | ||
public void testParseUnmarkCommand() throws InvalidArgumentException { | ||
Command command = Parser.parse("unmark 1"); | ||
assertTrue(command instanceof UnmarkCommand); | ||
} | ||
|
||
@Test | ||
public void testParseAddCommand() throws InvalidArgumentException { | ||
Command command = Parser.parse("todo Test"); | ||
assertTrue(command instanceof AddCommand); | ||
} | ||
|
||
@Test | ||
public void testParseExitCommand() throws InvalidArgumentException { | ||
Command command = Parser.parse("bye"); | ||
assertTrue(command instanceof ExitCommand); | ||
} | ||
|
||
@Test | ||
public void testInvalidCommand() { | ||
assertThrows(InvalidArgumentException.class, () -> Parser.parse("invalid_command")); | ||
} | ||
} |
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,48 @@ | ||
package duke; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.PrintStream; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class UiTest { | ||
private final PrintStream standardOut = System.out; | ||
private final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
System.setOut(new PrintStream(outputStreamCaptor)); | ||
} | ||
|
||
@Test | ||
public void testShowWelcome() { | ||
Ui ui = new Ui(); | ||
ui.showWelcome(); | ||
String expected = "__________________________________________________________________________" + | ||
" ___ _ ___ ________ __ ____ __________ ____ _ __\n" | ||
+ " / | / | / / | / / __ \\ \\/ / / __ \\ /_ __/ __ \\/ __ \\/ | / /\n" | ||
+ " / /| | / |/ / |/ / / / /\\ /_____/ / / /_____/ / / /_/ / / / / |/ / \n" | ||
+ " / ___ |/ /| / /| / /_/ / / /_____/ /_/ /_____/ / / _, _/ /_/ / /| / \n" | ||
+ "/_/ |_/_/ |_/_/ |_/\\____/ /_/ \\____/ /_/ /_/ |_|\\____/_/ |_/ \n" | ||
+ "Hello! I'm ANNOY-O-TRON!\nWhat can I do for you?\n" | ||
+ "__________________________________________________________________________"; | ||
assertEquals(expected, outputStreamCaptor.toString().trim()); | ||
} | ||
|
||
@Test | ||
public void testShowBye() { | ||
Ui ui = new Ui(); | ||
ui.showBye(); | ||
String expected = "Bye. Hope to see you again soon!"; | ||
assertEquals(expected, outputStreamCaptor.toString().trim()); | ||
} | ||
|
||
|
||
@AfterEach | ||
public void tearDown() { | ||
System.setOut(standardOut); | ||
} | ||
} |
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,21 @@ | ||
package duke.task; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class ToDoTest { | ||
@Test | ||
public void testToString() { | ||
Todo todo = new Todo("Sample Task"); | ||
String expected = "[T][ ] Sample Task"; | ||
assertEquals(expected, todo.toString()); | ||
} | ||
|
||
@Test | ||
public void testToFileString() { | ||
Todo todo = new Todo("Sample Task"); | ||
String expected = "T | 0 | Sample Task"; | ||
assertEquals(expected, todo.toFileString()); | ||
} | ||
} |