forked from AY2425S1-CS2103T-T12-4/tp
-
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
8 changed files
with
193 additions
and
108 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
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
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
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
39 changes: 39 additions & 0 deletions
39
src/test/java/seedu/address/logic/commands/AddGameCommandTest.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,39 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static seedu.address.logic.commands.CommandTestUtil.VALID_GAME; | ||
import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; | ||
import static seedu.address.testutil.TypicalIndexes.INDEX_FIRST_PERSON; | ||
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.Messages; | ||
import seedu.address.logic.commands.AddGameCommand.GameDescriptor; | ||
import seedu.address.model.AddressBook; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.game.Game; | ||
import seedu.address.model.person.Person; | ||
import seedu.address.testutil.EditPersonDescriptorBuilder; | ||
import seedu.address.testutil.GameDescriptorBuilder; | ||
import seedu.address.testutil.PersonBuilder; | ||
/** | ||
* Contains integration tests (interaction with the Model) and unit tests for AddGameCommand. | ||
*/ | ||
public class AddGameCommandTest { | ||
private Model model = new ModelManager(getTypicalAddressBook(), new UserPrefs()); | ||
@Test | ||
public void execute_allFieldsSpecifiedUnfilteredList_success() { | ||
Person editedPerson = new PersonBuilder().withGames(VALID_GAME).build(); | ||
GameDescriptor descriptor = new GameDescriptorBuilder().withGame(VALID_GAME).build(); | ||
|
||
AddGameCommand addCommand = new AddGameCommand(INDEX_FIRST_PERSON, VALID_GAME, descriptor); | ||
|
||
Game expectedGame = editedPerson.getGames().get(VALID_GAME); | ||
String expectedMessage = String.format(AddGameCommand.MESSAGE_ADD_GAME_SUCCESS, Messages.format(expectedGame)); | ||
Model expectedModel = new ModelManager(new AddressBook(model.getAddressBook()), new UserPrefs()); | ||
|
||
assertCommandSuccess(addCommand, model, expectedMessage, model); | ||
} | ||
} |
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
41 changes: 41 additions & 0 deletions
41
src/test/java/seedu/address/logic/commands/GameDescriptorTest.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,41 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static seedu.address.logic.commands.CommandTestUtil.DESC_GAME; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.testutil.GameDescriptorBuilder; | ||
|
||
public class GameDescriptorTest { | ||
|
||
@Test | ||
public void equals() { | ||
// same values -> returns true | ||
AddGameCommand.GameDescriptor descriptorWithSameValues = new AddGameCommand.GameDescriptor(DESC_GAME); | ||
assertTrue(DESC_GAME.equals(descriptorWithSameValues)); | ||
|
||
// same object -> returns true | ||
assertTrue(DESC_GAME.equals(DESC_GAME)); | ||
|
||
// null -> returns false | ||
assertFalse(DESC_GAME.equals(null)); | ||
|
||
// different types -> returns false | ||
assertFalse(DESC_GAME.equals(5)); | ||
|
||
// different username -> returns false | ||
AddGameCommand.GameDescriptor editedGame = new GameDescriptorBuilder(DESC_GAME).withUsername("Bob").build(); | ||
assertFalse(DESC_GAME.equals(editedGame)); | ||
|
||
// different role -> returns false | ||
editedGame = new GameDescriptorBuilder(DESC_GAME).withRole("DPS").build(); | ||
assertFalse(DESC_GAME.equals(editedGame)); | ||
|
||
// different skillLevel -> returns false | ||
editedGame = new GameDescriptorBuilder(DESC_GAME).withSkillLevel("Noob").build(); | ||
assertFalse(DESC_GAME.equals(editedGame)); | ||
} | ||
|
||
} |
Oops, something went wrong.