|
@@ -4,7 +4,57 @@ package io.zipcoder.casino;
|
4
|
4
|
import org.junit.Assert;
|
5
|
5
|
import org.junit.Test;
|
6
|
6
|
|
|
7
|
+import java.io.ByteArrayInputStream;
|
|
8
|
+import java.util.NoSuchElementException;
|
|
9
|
+import java.util.Scanner;
|
|
10
|
+
|
7
|
11
|
public class CasinoTest {
|
8
|
12
|
|
|
13
|
+ @Test
|
|
14
|
+ public void testYahtzee(){
|
|
15
|
+ String test = "1";
|
|
16
|
+
|
|
17
|
+ Casino casino = new Casino();
|
|
18
|
+ Console console = new Console();
|
|
19
|
+
|
|
20
|
+ casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(test.getBytes())));
|
|
21
|
+ try {
|
|
22
|
+ casino.chooseGame();
|
|
23
|
+ }catch(NoSuchElementException e){
|
|
24
|
+
|
|
25
|
+ }
|
|
26
|
+
|
|
27
|
+ Assert.assertTrue(casino.getGame() instanceof Yahtzee);
|
|
28
|
+ }
|
|
29
|
+
|
|
30
|
+ @Test
|
|
31
|
+ public void testGetStudPlayer(){
|
|
32
|
+
|
|
33
|
+ int num = 0;
|
|
34
|
+ String test = "2";
|
|
35
|
+ Casino casino = new Casino();
|
|
36
|
+ Stud stud = new Stud(10);
|
|
37
|
+
|
|
38
|
+ casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(test.getBytes())));
|
|
39
|
+ try {
|
|
40
|
+ num = casino.getStudPlayers();
|
|
41
|
+ }catch(NoSuchElementException e){
|
|
42
|
+
|
|
43
|
+ }
|
|
44
|
+ System.out.println(num);
|
|
45
|
+ Assert.assertTrue(num == 2);
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ @Test
|
|
49
|
+ public void testWar(){
|
|
50
|
+ Casino casino = new Casino();
|
|
51
|
+ String input = "jon \n 100 \n 2 \n flip";
|
|
52
|
+
|
|
53
|
+ casino.getConsole().setScanner(new Scanner(new ByteArrayInputStream(input.getBytes())));
|
|
54
|
+ try {
|
|
55
|
+ casino.getConsole().createAccount();
|
|
56
|
+ }catch(NoSuchElementException e){
|
9
|
57
|
|
|
58
|
+ }
|
|
59
|
+ }
|
10
|
60
|
}
|