-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathYourPlayerTest.java
More file actions
66 lines (47 loc) · 1.66 KB
/
YourPlayerTest.java
File metadata and controls
66 lines (47 loc) · 1.66 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
58
59
60
61
62
63
64
65
66
package com.hangman.players;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collections;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
import static java.lang.String.valueOf;
public class YourPlayerTest {
@Test
public void alwaysGuessesACharacter() {
YourPlayer player = new YourPlayer();
for (int i = 0; i < 100; i++) {
char guess = player.GetGuess(Arrays.asList('_', '_', '_'));
assertTrue(Character.isAlphabetic(guess));
assertFalse(Character.isDigit(guess));
}
}
@Test
public void shouldNotGuessTheSameCharacterUntilAllOtherCharacterTried() {
YourPlayer player = new YourPlayer();
player.addLetter('a');
for (int i = 0; i < 25; i++) {
char guess = player.GetGuess(Arrays.asList('_', '_', '_'));
assertNotEquals(valueOf(guess), valueOf('a'));
}
}
@Test
public void DoesNotGuessWhenWordIsSolved() {
YourPlayer player = new YourPlayer();
char guess = player.GetGuess(Arrays.asList('m', 'a', 'n'));
assertEquals(" ", valueOf(guess));
}
@Test
public void ShouldReturnIfPassedNullList() {
YourPlayer player = new YourPlayer();
char guess = player.GetGuess(null);
assertEquals(" ", valueOf(guess));
}
@Test
public void ShouldReturnIfPassedEmptyList() {
YourPlayer player = new YourPlayer();
char guess = player.GetGuess(Collections.emptyList());
assertEquals(" ", valueOf(guess));
}
}