Added current TranslationControllerTest class.
This commit is contained in:
parent
807faab075
commit
b4ee0f7f60
1 changed files with 11 additions and 13 deletions
|
@ -1,11 +1,12 @@
|
||||||
package uk.ac.aber.cs22120.group20.test;
|
package uk.ac.aber.cs22120.group20.test;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import uk.ac.aber.cs22120.group20.javafx.TranslationController;
|
||||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||||
import uk.ac.aber.cs22120.group20.selfassessment.AssessmentGenerator;
|
import uk.ac.aber.cs22120.group20.selfassessment.AssessmentGenerator;
|
||||||
import uk.ac.aber.cs22120.group20.selfassessment.Question;
|
import uk.ac.aber.cs22120.group20.selfassessment.Question;
|
||||||
import uk.ac.aber.cs22120.group20.selfassessment.TranslationController;
|
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -13,7 +14,7 @@ import java.util.Random;
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
public class TranslationControllerTest {
|
public class TranslationControllerTest {
|
||||||
LinkedList<DictionaryEntry> practiceList;
|
LinkedList<DictionaryEntry> practiceList = new LinkedList<>();
|
||||||
DictionaryEntry word1 = new DictionaryEntry("english1", "welsh1", "verb");
|
DictionaryEntry word1 = new DictionaryEntry("english1", "welsh1", "verb");
|
||||||
DictionaryEntry word2 = new DictionaryEntry("english2", "welsh2", "verb");
|
DictionaryEntry word2 = new DictionaryEntry("english2", "welsh2", "verb");
|
||||||
DictionaryEntry word3 = new DictionaryEntry("english3", "welsh3", "verb");
|
DictionaryEntry word3 = new DictionaryEntry("english3", "welsh3", "verb");
|
||||||
|
@ -23,32 +24,29 @@ public class TranslationControllerTest {
|
||||||
TranslationController controllerToTest = new TranslationController();
|
TranslationController controllerToTest = new TranslationController();
|
||||||
|
|
||||||
|
|
||||||
@Before
|
@BeforeEach
|
||||||
public void fillList(){
|
public void fillList(){
|
||||||
|
|
||||||
practiceList.add(word1);
|
practiceList.add(word1);
|
||||||
practiceList.add(word2);
|
practiceList.add(word2);
|
||||||
practiceList.add(word3);
|
practiceList.add(word3);
|
||||||
chosenWord = rand.nextInt(practiceList.size());
|
chosenWord = rand.nextInt(practiceList.size());
|
||||||
TranslationController.answer = practiceList.get(chosenWord);
|
TranslationController.answer = practiceList.get(0);
|
||||||
|
|
||||||
|
System.out.println(controllerToTest.wordToTranslate.getText());
|
||||||
|
|
||||||
if(AssessmentGenerator.isEnglish){
|
|
||||||
controllerToTest.wordToTranslate.setText(TranslationController.answer.getEnglish());
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
controllerToTest.wordToTranslate.setText(TranslationController.answer.getWelsh());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testText(){
|
public void testRightWord(){
|
||||||
|
|
||||||
if(AssessmentGenerator.isEnglish){
|
if(AssessmentGenerator.isEnglish){
|
||||||
assertEquals(practiceList.get(chosenWord).getEnglish(),TranslationController.answer.getEnglish());
|
assertEquals(TranslationController.answer.getEnglish(), controllerToTest.wordToTranslate.getText());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
assertEquals("welsh1", controllerToTest.wordToTranslate.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue