forked from nus-cs2103-AY1920S1/addressbook-level3
-
Notifications
You must be signed in to change notification settings - Fork 5
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
12 changed files
with
158 additions
and
30 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
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
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
53 changes: 53 additions & 0 deletions
53
src/test/java/seedu/address/logic/commands/RateQuestionCommandTest.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,53 @@ | ||
package seedu.address.logic.commands; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import seedu.address.logic.parser.KeyboardFlashCardsParser; | ||
import seedu.address.model.KeyboardFlashCards; | ||
import seedu.address.model.Model; | ||
import seedu.address.model.ModelManager; | ||
import seedu.address.model.UserPrefs; | ||
import seedu.address.model.flashcard.FlashCard; | ||
import seedu.address.model.flashcard.Rating; | ||
import seedu.address.model.flashcard.exceptions.FlashCardNotFoundException; | ||
import seedu.address.testutil.FlashCardTestListBuilder; | ||
|
||
//@@author keiteo | ||
public class RateQuestionCommandTest { | ||
|
||
private KeyboardFlashCardsParser keyboardFlashCardsParser = new KeyboardFlashCardsParser(); | ||
|
||
@Test | ||
public void execute_flashCardDoesNotExist_exceptionThrown() { | ||
String[] ratings = {"good", "hard", "easy"}; | ||
for (String rate : ratings) { | ||
Model model = initModel(new ModelManager()); | ||
Command cmd = new RateQuestionCommand(keyboardFlashCardsParser, new Rating(rate)); | ||
assertThrows(FlashCardNotFoundException.class, () -> cmd.execute(model)); | ||
} | ||
} | ||
|
||
@Test | ||
public void execute_goodRatingFlashCardExists_success() { | ||
KeyboardFlashCards keyboardFlashCards = new KeyboardFlashCards(); | ||
FlashCard fc = new FlashCardTestListBuilder().buildOne().get(0); | ||
keyboardFlashCards.addFlashcard(fc); | ||
Model model = initModel(new ModelManager(keyboardFlashCards, new UserPrefs())); | ||
try { | ||
Command cmd = new RateQuestionCommand(keyboardFlashCardsParser, new Rating("good")); | ||
cmd.execute(model); | ||
} catch (Exception e) { | ||
fail(); | ||
} | ||
} | ||
|
||
/** Loads the model with a prebuilt list of test FlashCards. */ | ||
private Model initModel(Model model) { | ||
model.initializeTestModel(new FlashCardTestListBuilder().buildOne()); | ||
model.setTestFlashCard(); | ||
return model; | ||
} | ||
} |
Oops, something went wrong.