-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUtilityTest.java
59 lines (52 loc) · 1.57 KB
/
UtilityTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package com.company;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.*;
public class UtilityTest {
Quiz quiz = new Quiz();
@Test
public void shuffleList() throws Exception
{
quiz.clearQuestionsList();
quiz.modifyQuestionsList(Config.path);
List<Question> list = quiz.questionsList;
Utility.shuffleList(quiz.questionsList);
List<Question> shuffledList = quiz.questionsList;
boolean areEqual = true;
for(int j = 0; j < quiz.questionsList.size(); j++)
{
if(!list.get(j).equals(shuffledList.get(j)));
{
areEqual = false;
}
}
assertFalse(areEqual);
}
@Test
public void isNumeric()
{
assertTrue(Utility.isNumeric("3"));
assertFalse(Utility.isNumeric("quz"));
assertFalse(Utility.isNumeric("?"));
}
@Test
public void shuffleArray() throws Exception
{
quiz.clearQuestionsList();
OneAnswerQuestion newQuestion = new OneAnswerQuestion();
newQuestion.possibleAnswers = new String[]{"2", "2", "3"};
String[] array = newQuestion.possibleAnswers;
Utility.shuffleArray(newQuestion.possibleAnswers);
String[] newArray = newQuestion.possibleAnswers;
boolean areEqual;
areEqual = true;
for(int i = 0; i < newQuestion.possibleAnswers.length; i++)
{
if(!array[i].equals(newArray[i]));
{
areEqual = false;
}
}
assertFalse(areEqual);
}
}