Newer
Older
package model
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.doReturn
import com.nhaarman.mockitokotlin2.whenever
import org.assertj.core.api.Assertions.assertThat
import org.assertj.core.api.Condition
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.BeforeEach
import org.mockito.Mockito
internal class GameTest {
var thirdDeck = Mockito.spy(Deck::class.java)
var secondDeck = GamePile(mutableListOf(HeartCard(false, 5), ClubCard(true, 6)))
@BeforeEach
fun setUp() {
doReturn(true).whenever(thirdDeck).pileCompatibilityCheck(any())
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
}
@Test
fun place() {
(Game.gamePiles as MutableList)[2] = thirdDeck
(Game.gamePiles as MutableList)[1] = secondDeck
Game.place(1, 2)
assertThat(Game.gamePiles[1])
.has(Condition({ deck -> deck.top == HeartCard(true, 5)}, "Top value"))
.has(Condition({deck -> deck.cards.size == 1}, "One value"))
assertThat(Game.gamePiles[2].top).isEqualTo(ClubCard(true, 6))
assertThat(Game.gamePiles[2].cards).hasSize(1)
Game.place(1,2)
assertThat(Game.gamePiles[1])
.has(Condition({ deck -> deck.top == null}, "Top value null"))
.has(Condition({deck -> deck.cards.isEmpty()}, "Empty deck"))
assertThat(Game.gamePiles[2].top).isEqualTo(HeartCard(true, 5))
assertThat(Game.gamePiles[2].cards).hasSize(2)
}
@Test
fun draw() {
Game.visibleDeck.removeAll()
Game.visibleDeck += HeartCard(true, 5)
Game.visibleDeck += HeartCard(true, 6)
Game.stack.removeAll()
Game.draw()
assertThat(Game.visibleDeck.cards).isEmpty()
assertThat(Game.stack.cards).isEqualTo(mutableListOf(HeartCard(false, 6), HeartCard(false, 5)))
}
@Test
fun store() {
}
}