-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathYourPlayerTest.java
More file actions
47 lines (37 loc) · 1.07 KB
/
YourPlayerTest.java
File metadata and controls
47 lines (37 loc) · 1.07 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
package com.hangman.players;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
public class YourPlayerTest {
YourPlayer player = new YourPlayer();
@Test
public void DoesNotGuessAIfExists() {
char guess = player.GetGuess(Arrays.asList('_', 'a'));
assertNotEquals('a', guess);
}
@Test
public void DoesNotGuessCharactersThatExist() {
for(char c = 'a'; c <= 'z'; c++){
List<Character> clue = allLetters();
clue.remove((Character) c);
clue.add('_');
char guess = player.GetGuess(clue);
assertEquals("Expected: " + c + " got: " + guess, c, guess);
}
}
@Test
public void guessesTWhenEExists(){
char guess = player.GetGuess(Arrays.asList('_', 'e'));
assertEquals('t', guess);
}
//case
private static List<Character> allLetters(){
List<Character> result = new ArrayList();
for(char c = 'a'; c <= 'z'; c++){
result.add(c);
}
return result;
}
}