Merge branch 'master' of https://gitlab.dcs.aber.ac.uk/ncw/gp20
This commit is contained in:
commit
643de20ef9
2 changed files with 61 additions and 24 deletions
|
@ -171,9 +171,9 @@ public class AssessmentGenerator {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("You scored: ")
|
sb.append("You got ")
|
||||||
.append(Question.correctAnswers).append("/")
|
.append(Question.correctAnswers / (Question.correctAnswers + Question.wrongAnswers))
|
||||||
.append(Question.correctAnswers + Question.wrongAnswers)
|
.append("%")
|
||||||
.append("\n Would you like to test yourself again?");
|
.append("\n Would you like to test yourself again?");
|
||||||
|
|
||||||
ButtonType yesBtn = new ButtonType("Yes");
|
ButtonType yesBtn = new ButtonType("Yes");
|
||||||
|
|
|
@ -10,14 +10,34 @@ import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
import static uk.ac.aber.cs22120.group20.json.DictionaryEntry.wordTypeEnum.verb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class that contains methods which will be used to test the Question class, and its methods.
|
||||||
|
* @author Brad Corbett [brc9]
|
||||||
|
* @author Henry Dugmore [hjd3]
|
||||||
|
* @author Kain Bryan-Jones [kab74]
|
||||||
|
* @author Luke Wybar [law39]
|
||||||
|
* @author Marcin Jakob [maj83]
|
||||||
|
* @author Oscar Pocock [osp1]
|
||||||
|
* @author Tom Perry [top1]
|
||||||
|
* @author Waylen Watts [ncw]
|
||||||
|
* @version 0.1 Initial development
|
||||||
|
* @See Question
|
||||||
|
*/
|
||||||
|
|
||||||
class QuestionTest {
|
class QuestionTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the correctAnswers variable increments when a user gets a right answer
|
||||||
|
* when doing either a Translation or SixMeanings test.
|
||||||
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCheckRightAnswerTranslation() {
|
void testCheckRightAnswerTranslationOrSixMeanings() {
|
||||||
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
||||||
ArrayList<String> correctEntryList = new ArrayList<>();
|
ArrayList<String> correctEntryList = new ArrayList<>();
|
||||||
DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1","verb");
|
DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1",verb);
|
||||||
boolean isEnglish = true;
|
boolean isEnglish = true;
|
||||||
|
|
||||||
correctAnswerList.add(wordToTest);
|
correctAnswerList.add(wordToTest);
|
||||||
|
@ -32,11 +52,16 @@ class QuestionTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the wrongAnswers variable increments when a user gets a wrong answer
|
||||||
|
* when doing either a Translation or SixMeanings test.
|
||||||
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCheckWrongAnswerTranslation() {
|
void testCheckWrongAnswerTranslationOrSixMeanings() {
|
||||||
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
||||||
ArrayList<String> correctEntryList = new ArrayList<>();
|
ArrayList<String> correctEntryList = new ArrayList<>();
|
||||||
DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1","verb");
|
DictionaryEntry wordToTest = new DictionaryEntry("english1", "welsh1",verb);
|
||||||
boolean isEnglish = true;
|
boolean isEnglish = true;
|
||||||
|
|
||||||
correctAnswerList.add(wordToTest);
|
correctAnswerList.add(wordToTest);
|
||||||
|
@ -44,6 +69,8 @@ class QuestionTest {
|
||||||
|
|
||||||
Question question;
|
Question question;
|
||||||
|
|
||||||
|
Question.resetScore();
|
||||||
|
|
||||||
Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish);
|
Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish);
|
||||||
|
|
||||||
assertEquals(1, Question.wrongAnswers);
|
assertEquals(1, Question.wrongAnswers);
|
||||||
|
@ -51,14 +78,20 @@ class QuestionTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the correctAnswers variable increments when a user gets a right answer
|
||||||
|
* when doing either a MatchTheMeaning test.
|
||||||
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCheckRightAnswerMatchMeaning(){
|
void testCheckRightAnswerMatchMeaning(){
|
||||||
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
||||||
ArrayList<String> correctEntryList = new ArrayList<>();
|
ArrayList<String> correctEntryList = new ArrayList<>();
|
||||||
DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1","verb");
|
DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1",verb);
|
||||||
DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2","verb");
|
DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2",verb);
|
||||||
DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3","verb");
|
DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3",verb);
|
||||||
DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4","verb");
|
DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4",verb);
|
||||||
boolean isEnglish = true;
|
boolean isEnglish = true;
|
||||||
|
|
||||||
correctAnswerList.add(wordToTest1);
|
correctAnswerList.add(wordToTest1);
|
||||||
|
@ -72,19 +105,26 @@ class QuestionTest {
|
||||||
|
|
||||||
AssessmentGenerator.isEnglish = true;
|
AssessmentGenerator.isEnglish = true;
|
||||||
|
|
||||||
|
Question.resetScore();
|
||||||
|
|
||||||
Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish);
|
Question.checkAnswer(correctAnswerList, correctEntryList, isEnglish);
|
||||||
|
|
||||||
assertEquals(4, Question.correctAnswers);
|
assertEquals(4, Question.correctAnswers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests that the wrongAnswers variable increments when a user gets a wrong answer
|
||||||
|
* when doing either a MatchTheMeaning test.
|
||||||
|
*/
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCheckWrongAnswerMatchMeaning(){
|
void testCheckWrongAnswerMatchMeaning(){
|
||||||
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
ArrayList<DictionaryEntry> correctAnswerList = new ArrayList<>();
|
||||||
ArrayList<String> correctEntryList = new ArrayList<>();
|
ArrayList<String> correctEntryList = new ArrayList<>();
|
||||||
DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1","verb");
|
DictionaryEntry wordToTest1 = new DictionaryEntry("english1", "welsh1",verb);
|
||||||
DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2","verb");
|
DictionaryEntry wordToTest2 = new DictionaryEntry("english2", "welsh2",verb);
|
||||||
DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3","verb");
|
DictionaryEntry wordToTest3 = new DictionaryEntry("english3", "welsh3",verb);
|
||||||
DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4","verb");
|
DictionaryEntry wordToTest4 = new DictionaryEntry("english4", "welsh4",verb);
|
||||||
|
|
||||||
|
|
||||||
correctAnswerList.add(wordToTest1);
|
correctAnswerList.add(wordToTest1);
|
||||||
|
@ -105,17 +145,14 @@ class QuestionTest {
|
||||||
assertEquals(4, Question.wrongAnswers);
|
assertEquals(4, Question.wrongAnswers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
void testCheckRightAnswerSixMeanings(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void testCheckWrongAnswerSixMeanings(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void resetScore() {
|
void resetScore() {
|
||||||
|
Question.wrongAnswers = 5;
|
||||||
|
Question.correctAnswers = 5;
|
||||||
|
Question.resetScore();
|
||||||
|
|
||||||
|
assertEquals(0, Question.correctAnswers);
|
||||||
|
assertEquals(0, Question.wrongAnswers);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in a new issue