-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplayer_state_test.go
101 lines (83 loc) · 1.7 KB
/
player_state_test.go
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package main
import (
"testing"
)
func newTestState() PlayerState {
return PlayerState{
hand: []string{"a", "b", "b"},
boardTapped: make([]string, 0),
boardUntapped: make([]string, 0),
}
}
func TestPlayStateCardTapped(t *testing.T) {
// Arrange
ts := newTestState()
// Act
ts.PlayCard("a", true)
// Assert
if len(ts.hand) != 2 || ts.hand[0] != "b" {
t.Log("Card in hand is wrong.")
t.Fail()
}
if len(ts.boardTapped) != 1 || ts.boardTapped[0] != "a" {
t.Log("Card played tapped is wrong.")
t.Fail()
}
if len(ts.boardUntapped) != 0 {
t.Log("Card played untapped is wrong.")
t.Fail()
}
}
func TestPlayStateCardUntapped(t *testing.T) {
// Arrange
ts := newTestState()
// Act
ts.PlayCard("b", false)
// Assert
if len(ts.boardUntapped) != 1 {
t.Log("Only one card should be played at a time..")
t.Fail()
}
if ts.boardUntapped[0] != "b" {
t.Log("Card played tapped is wrong.")
t.Fail()
}
}
func TestDraw(t *testing.T) {
// Arrange
ts := PlayerState{
library: []string{"a", "b"},
hand: make([]string, 0),
boardTapped: make([]string, 0),
boardUntapped: make([]string, 0),
}
// Act
ts.DrawCard()
// Assert
if len(ts.hand) != 1 || ts.hand[0] != "a" {
t.Log("Card in hand is wrong.")
t.Fail()
}
if len(ts.library) != 1 || ts.library[0] != "b" {
t.Log("Cards in library is wrong.")
t.Fail()
}
}
func TestUntap(t *testing.T) {
// Arrange
ts := PlayerState{
boardTapped: []string{"a", "b"},
boardUntapped: make([]string, 0),
}
// Act
ts.Untap()
// Assert
if len(ts.boardTapped) != 0 {
t.Log("Stuff's still tapped.")
t.Fail()
}
if len(ts.boardUntapped) != 2 {
t.Log("Cards in untapped is wrong.")
t.Fail()
}
}