public void tearDown() {
}
@Test
public void bagAccessTester() {
Bag bag = GAME.bag();
try {
bag.initWithLanguage("");
}
catch (NullPointerException e) {
System.out.println("Language doesn't not exist.");
}
try {
bag.initWithLanguage("English");
System.out.println("Initialize bag");
}
catch (NullPointerException e) {
fail("NullPointerException was not expected");
}
try {
bag.fill();
System.out.println("Fill bag");
}
catch (ArrayIndexOutOfBoundsException e) {
fail("ArrayIndexOutOfBoundsException was not expected");
}
try {
boolean expResult = false;
boolean result = bag.isEmpty();
assertEquals(expResult, result);
System.out.println("Bag is not empty");
}
catch (ArrayIndexOutOfBoundsException e) {
fail("ArrayIndexOutOfBoundsException was not expected");
}
try {
Letter letter = null;
bag.addLetter(letter);
System.out.println("Can add a null letter in bag");
}
catch (NullPointerException ex) {
fail("NullPointerException was not expected");
}
try {
String word = "";
int expResult = 0;
int result = bag.getWordValue(word);
assertEquals(expResult, result);
System.out.println("getWordValue");
}
catch (NullPointerException e) {
fail("NullPointerException was not expected");
}
try {
String letter = "";
int expResult = 0;
int result = bag.getLetterValue(letter);
assertEquals(expResult, result);
System.out.println("getLetterValue");
}
catch (NullPointerException e) {
fail("NullPointerException was not expected");
}
bag.clear();
if (bag.getRandomLetter() == null) {
System.out.println("Can't get a letter from empty bag");
}
else {
fail("null was expected");
}