diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java index eb1f36d..e40bc2d 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs22120/group20/test/TranslationControllerTest.java @@ -1,11 +1,12 @@ package uk.ac.aber.cs22120.group20.test; import org.junit.Before; +import org.junit.jupiter.api.BeforeEach; 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.selfassessment.AssessmentGenerator; import uk.ac.aber.cs22120.group20.selfassessment.Question; -import uk.ac.aber.cs22120.group20.selfassessment.TranslationController; import java.util.LinkedList; import java.util.Random; @@ -13,7 +14,7 @@ import java.util.Random; import static org.junit.jupiter.api.Assertions.*; public class TranslationControllerTest { - LinkedList practiceList; + LinkedList practiceList = new LinkedList<>(); DictionaryEntry word1 = new DictionaryEntry("english1", "welsh1", "verb"); DictionaryEntry word2 = new DictionaryEntry("english2", "welsh2", "verb"); DictionaryEntry word3 = new DictionaryEntry("english3", "welsh3", "verb"); @@ -23,32 +24,29 @@ public class TranslationControllerTest { TranslationController controllerToTest = new TranslationController(); - @Before + @BeforeEach public void fillList(){ practiceList.add(word1); practiceList.add(word2); practiceList.add(word3); 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 - public void testText(){ + public void testRightWord(){ + if(AssessmentGenerator.isEnglish){ - assertEquals(practiceList.get(chosenWord).getEnglish(),TranslationController.answer.getEnglish()); + assertEquals(TranslationController.answer.getEnglish(), controllerToTest.wordToTranslate.getText()); } else{ - + assertEquals("welsh1", controllerToTest.wordToTranslate.getText()); } }