forked from nus-cs2103-AY1617S2/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 changed file
with
43 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,43 @@ | ||
# A0148052L | ||
###### /java/guitests/SaveCommandTest.java | ||
``` java | ||
package guitests; | ||
|
||
import org.junit.Test; | ||
|
||
import onlythree.imanager.logic.commands.SaveCommand; | ||
|
||
public class SaveCommandTest extends TaskListGuiTest { | ||
|
||
@Test | ||
public void saveFile_relativeFilePath_successful() { | ||
String filePath = "data" + "\\" + "taskList.xml"; | ||
assertSaveSuccess(filePath); | ||
} | ||
|
||
@Test | ||
public void saveFile_relativeFileName_fileNameError() { | ||
commandBox.runCommand("save " + "data" + "\\" + ".xml"); | ||
assertResultMessage(SaveCommand.MESSAGE_INVALID_FILE_NAME); | ||
} | ||
|
||
private void assertSaveSuccess(String filePath) { | ||
commandBox.runCommand("save " + filePath); | ||
assertResultMessage(String.format(SaveCommand.MESSAGE_SUCCESS, filePath)); | ||
} | ||
} | ||
``` | ||
###### /java/onlythree/imanager/logic/LogicManagerTest.java | ||
``` java | ||
public void execute_save_successful() throws Exception { | ||
assertCommandSuccess("save " + saveFolder.getRoot().getPath() + File.separator + "taskList.xml", | ||
SaveCommand.MESSAGE_SUCCESS, new TaskList(), Collections.emptyList()); | ||
} | ||
|
||
@Test | ||
public void execute_save_invalidFileName() throws Exception { | ||
List<ReadOnlyTask> expectedShownList = new ArrayList<>(model.getFilteredTaskList()); | ||
assertCommandBehavior(false, "save " + "data" + "\\" + ".xml", | ||
SaveCommand.MESSAGE_INVALID_FILE_NAME, new TaskList(), expectedShownList); | ||
} | ||
``` |