-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathYourPlayerTest.java
More file actions
57 lines (40 loc) · 1.6 KB
/
YourPlayerTest.java
File metadata and controls
57 lines (40 loc) · 1.6 KB
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
package com.hangman.players;
import org.junit.Test;
import java.util.Arrays;
import static org.junit.Assert.assertEquals;
public class YourPlayerTest {
private static final String[] wordsForTest = {
"abc",
"acc",
"something_longer",
"somethingshorter"
};
@Test
public void GuessesWhenThereAreNoSuccessfulCharactersGuessedYet() {
YourPlayer player = new YourPlayer(wordsForTest);
// last character of the first 3 chars long word
char shortGuess = player.GetGuess(Arrays.asList('_', '_', '_'));
assertEquals('c', shortGuess);
// last character of the first 16 chars long word
char longGuess = player.GetGuess(Arrays.asList('_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_', '_'));
assertEquals('r', longGuess);
}
@Test
public void GuessesWhenThereAreSuccessfulCharactersGuessedAndThereIsNoMatchingKnownWord() {
YourPlayer player = new YourPlayer(wordsForTest);
char guess1 = player.GetGuess(Arrays.asList('m', '_', 'n'));
assertEquals('a', guess1);
}
@Test
public void GuessesWhenThereAreSuccessfulCharactersGuessedAndThereIsAMatchingKnownWord() {
YourPlayer player = new YourPlayer(wordsForTest);
char guess2 = player.GetGuess(Arrays.asList('a', '_', 'b'));
assertEquals('c', guess2);
}
@Test
public void GuessesFirstCharacterOfACompleteClue() {
YourPlayer player = new YourPlayer(wordsForTest);
char guess = player.GetGuess(Arrays.asList('a', 'b', 'c'));
assertEquals('a', guess);
}
}