forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 4
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
71 additions
and
5 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
40 changes: 40 additions & 0 deletions
40
src/test/java/seedu/address/logic/commands/AliasCommandIntegrationTest.java
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,40 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
|
||
public class AliasCommandIntegrationTest { | ||
private Model model; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
} | ||
|
||
@Test | ||
public void execute_newAlias_success() { | ||
String alias = "TEST ALIAS"; | ||
String aliasTo = "help"; | ||
|
||
Model expectedModel = new ModelManager(model.getAddressBook(), new UserPrefs()); | ||
expectedModel.addAlias(alias, aliasTo); | ||
|
||
assertCommandSuccess(new AliasCommand(alias, aliasTo), model, | ||
String.format(AliasCommand.MESSAGE_SUCCESS, alias, aliasTo), expectedModel); | ||
} | ||
|
||
@Test | ||
public void execute_overridingExistingCommand_throwsCommandException() { | ||
String alias = "help"; | ||
String aliasTo = "exit"; | ||
assertCommandFailure(new AliasCommand(alias, aliasTo), model, AliasCommand.MESSAGE_ALIAS_FAILED); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/java/seedu/address/logic/commands/AliasListCommandTest.java
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,26 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
|
||
public class AliasListCommandTest { | ||
private Model model = new ModelManager(); | ||
private Model expectedModel = new ModelManager(); | ||
|
||
|
||
@Test | ||
public void execute_aliasList_success() { | ||
String expectedStringForDefaultAliasTable = "a ⟶ add\n" | ||
+ "<meta http-equiv=\"refresh\" content=\"0; URL='http://example.org'\" /> ⟶ aliaslist\n" | ||
+ "e ⟶ exit\n" | ||
+ "h ⟶ help\n"; | ||
CommandResult expectedCommandResult = new CommandResult(expectedStringForDefaultAliasTable, | ||
false, false, false, false, false, false, false, true); | ||
System.out.println((new AliasListCommand().execute(model).getFeedbackToUser())); | ||
assertCommandSuccess(new AliasListCommand(), model, expectedCommandResult, expectedModel); | ||
} | ||
} |