-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathYourPlayerTest.java
More file actions
61 lines (49 loc) · 1.65 KB
/
YourPlayerTest.java
File metadata and controls
61 lines (49 loc) · 1.65 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
package com.hangman.players;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
public class YourPlayerTest {
private YourPlayer player;
@Before
public void setUp() {
player = new YourPlayer();
}
@Test
public void GetLatestClueShouldReturnNothing() {
assertNull(player.GetLatestClue());
}
@Test
public void GetGuessShouldReturnFirstElementInMostCommonLetterList() {
char guess = player.GetGuess(Arrays.asList('_', '_', '_'));
assertEquals(guess, YourPlayer.mostCommon2LeastLetters.get(0).charValue());
}
@Test
public void GetGuessShouldReturnZeroWhenClueIsNull() {
char c = player.GetGuess(null);
assertTrue(c == 0);
}
@Test
public void GetGuessShouldAlwaysReturnElementInMostCommonLetterList() {
for(int i = 0; i < YourPlayer.mostCommon2LeastLetters.size(); i++) {
char guess = player.GetGuess(Arrays.asList('_', '_', '_'));
assertTrue(Character.isAlphabetic(guess));
}
}
@Test
public void GetGuessShouldNotReturnLetterMorN() {
for(int i = 0; i < YourPlayer.mostCommon2LeastLetters.size(); i++) {
char c = player.GetGuess(Arrays.asList('m', '_', 'n'));
assertNotEquals(c, 'm');
assertNotEquals(c, 'n');
}
}
@Test
public void GetLatestClueShouldMatchInitialClueList() {
List <Character> clue = Arrays.asList('_', '_', '_');
player.GetGuess(Arrays.asList('_', '_', '_'));
assertEquals(clue, player.GetLatestClue());
}
}