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
1 parent
90e23e4
commit 7618a5b
Showing
5 changed files
with
185 additions
and
17 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
Binary file not shown.
46 changes: 46 additions & 0 deletions
46
src/test/java/seedu/tarence/logic/commands/AddModuleCommandTest.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,46 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import static seedu.tarence.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.tarence.testutil.Assert.assertThrows; | ||
import static seedu.tarence.testutil.TypicalPersons.getTypicalApplication; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.tarence.model.Model; | ||
import seedu.tarence.model.ModelManager; | ||
import seedu.tarence.model.UserPrefs; | ||
import seedu.tarence.model.builder.ModuleBuilder; | ||
import seedu.tarence.model.module.Module; | ||
import seedu.tarence.model.module.exceptions.DuplicateModuleException; | ||
|
||
public class AddModuleCommandTest { | ||
public static final String VALID_MOD_CODE = "GER1000"; | ||
|
||
@Test | ||
public void execute_correctArguments_moduleAdded() { | ||
Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
Model expectedModel = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); | ||
|
||
expectedModel.addModule(validModule); | ||
|
||
assertCommandSuccess(new AddModuleCommand(validModule), model, | ||
String.format(AddModuleCommand.MESSAGE_SUCCESS, validModule), expectedModel); | ||
} | ||
|
||
@Test | ||
public void constructor_nullPerson_throwsNullPointerException() { | ||
assertThrows(NullPointerException.class, () -> new AddModuleCommand(null)); | ||
} | ||
|
||
@Test | ||
public void execute_duplicateModule_throwsDuplicateException() { | ||
Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); | ||
model.addModule(validModule); | ||
|
||
assertThrows(DuplicateModuleException.class, () -> model.addModule(validModule)); | ||
} | ||
|
||
|
||
} |
64 changes: 64 additions & 0 deletions
64
src/test/java/seedu/tarence/logic/commands/DeleteModuleVerifiedCommandTest.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,64 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import static seedu.tarence.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.tarence.testutil.TypicalPersons.getTypicalApplication; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.tarence.model.Model; | ||
import seedu.tarence.model.ModelManager; | ||
import seedu.tarence.model.UserPrefs; | ||
import seedu.tarence.model.builder.ModuleBuilder; | ||
import seedu.tarence.model.module.Module; | ||
|
||
public class DeleteModuleVerifiedCommandTest { | ||
|
||
|
||
public static final String VALID_MOD_CODE = "GER1000"; | ||
|
||
@Test | ||
public void execute_model_moduleDeleted() { | ||
ModuleBuilder.DEFAULT_TUTORIALS.clear(); | ||
Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
Model expectedModel = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); | ||
model.addModule(validModule); | ||
|
||
|
||
assertCommandSuccess(new DeleteModuleVerifiedCommand(validModule), model, | ||
"Deleted Module: " + VALID_MOD_CODE + " | ", expectedModel); | ||
} | ||
|
||
@Test | ||
public void needsInput_returnsTrue() { | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); | ||
DeleteModuleVerifiedCommand deleteModuleVerifiedCommand = new DeleteModuleVerifiedCommand(validModule); | ||
|
||
assertTrue(deleteModuleVerifiedCommand.needsInput()); | ||
} | ||
|
||
@Test | ||
public void needsCommand_confirmsYesCommand_returnsTrue() { | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); | ||
DeleteModuleVerifiedCommand deleteModuleVerifiedCommand = new DeleteModuleVerifiedCommand(validModule); | ||
|
||
ConfirmNoCommand confirmNoCommand = new ConfirmNoCommand(); | ||
|
||
assertTrue(deleteModuleVerifiedCommand.needsCommand(confirmNoCommand)); | ||
|
||
} | ||
|
||
@Test | ||
public void needsCommand_confirmNoCommand_returnsTrue() { | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MOD_CODE).build(); | ||
DeleteModuleVerifiedCommand deleteModuleVerifiedCommand = new DeleteModuleVerifiedCommand(validModule); | ||
ConfirmYesCommand confirmYesCommand = new ConfirmYesCommand(); | ||
assertTrue(deleteModuleVerifiedCommand.needsCommand(confirmYesCommand)); | ||
|
||
} | ||
|
||
|
||
} | ||
|
73 changes: 73 additions & 0 deletions
73
src/test/java/seedu/tarence/logic/commands/DeleteTutorialVerifiedCommandTest.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,73 @@ | ||
package seedu.tarence.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.tarence.logic.commands.CommandTestUtil.VALID_MODULE_AMY; | ||
import static seedu.tarence.logic.commands.CommandTestUtil.VALID_TUTORIAL_NAME_AMY; | ||
import static seedu.tarence.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.tarence.testutil.TypicalPersons.getTypicalApplication; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.tarence.model.Model; | ||
import seedu.tarence.model.ModelManager; | ||
import seedu.tarence.model.UserPrefs; | ||
import seedu.tarence.model.builder.ModuleBuilder; | ||
import seedu.tarence.model.builder.TutorialBuilder; | ||
import seedu.tarence.model.module.Module; | ||
import seedu.tarence.model.tutorial.Tutorial; | ||
|
||
public class DeleteTutorialVerifiedCommandTest { | ||
|
||
@Test | ||
public void execute_model_tutorialToBeDeleted() { | ||
ModuleBuilder.DEFAULT_TUTORIALS.clear(); | ||
TutorialBuilder.DEFAULT_STUDENTS.clear(); | ||
Module validModule = new ModuleBuilder().withModCode(VALID_MODULE_AMY).build(); | ||
Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) | ||
.withModCode(VALID_MODULE_AMY).build(); | ||
|
||
Model model = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
Model expectedModel = new ModelManager(getTypicalApplication(), new UserPrefs()); | ||
|
||
expectedModel.addModule(validModule); | ||
model.addModule(validModule); | ||
|
||
model.addTutorial(validTutorial); | ||
model.addTutorialToModule(validTutorial); | ||
|
||
assertCommandSuccess(new DeleteTutorialVerifiedCommand(validTutorial), model, | ||
"Deleted Tutorial: " + validTutorial.toString(), expectedModel); | ||
|
||
} | ||
|
||
@Test | ||
public void needsInput_returnsTrue() { | ||
Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) | ||
.withModCode(VALID_MODULE_AMY).build(); | ||
DeleteTutorialVerifiedCommand deleteTutorialVerifiedCommand = new DeleteTutorialVerifiedCommand(validTutorial); | ||
|
||
assertTrue(deleteTutorialVerifiedCommand.needsInput()); | ||
} | ||
|
||
@Test | ||
public void needsCommand_confirmsYesCommand_returnsTrue() { | ||
Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) | ||
.withModCode(VALID_MODULE_AMY).build(); | ||
DeleteTutorialVerifiedCommand deleteTutorialVerifiedCommand = new DeleteTutorialVerifiedCommand(validTutorial); | ||
|
||
ConfirmNoCommand confirmNoCommand = new ConfirmNoCommand(); | ||
|
||
assertTrue(deleteTutorialVerifiedCommand.needsCommand(confirmNoCommand)); | ||
|
||
} | ||
|
||
@Test | ||
public void needsCommand_confirmNoCommand_returnsTrue() { | ||
Tutorial validTutorial = new TutorialBuilder().withTutName(VALID_TUTORIAL_NAME_AMY) | ||
.withModCode(VALID_MODULE_AMY).build(); | ||
DeleteTutorialVerifiedCommand deleteTutorialVerifiedCommand = new DeleteTutorialVerifiedCommand(validTutorial); | ||
ConfirmYesCommand confirmYesCommand = new ConfirmYesCommand(); | ||
assertTrue(deleteTutorialVerifiedCommand.needsCommand(confirmYesCommand)); | ||
|
||
} | ||
} |