@@ -34,7 +34,7 @@ object CardManager {
|
||||
hand += nextCard()
|
||||
}
|
||||
Hand(hand.toList)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,39 +7,44 @@ import org.scalatest.wordspec.AnyWordSpec
|
||||
class DeckTests extends AnyWordSpec with Matchers{
|
||||
|
||||
"A deck" should {
|
||||
"The card container can't be empty" in {
|
||||
"not be empty" in {
|
||||
CardManager.cardContainer must not be empty
|
||||
}
|
||||
"A deck should have 52 cards" in {
|
||||
"have 52 cards" in {
|
||||
CardManager.cardContainer must have size 52
|
||||
}
|
||||
"There are 13 cards of spades" in {
|
||||
"contain 13 cards of spades" in {
|
||||
CardManager.cardContainer.count(_.suit == Suit.Spades) mustBe 13
|
||||
}
|
||||
"There are 13 cards of hearts" in {
|
||||
"contain cards of hearts" in {
|
||||
CardManager.cardContainer.count(_.suit == Suit.Hearts) mustBe 13
|
||||
}
|
||||
"There are 13 cards of diamonds" in {
|
||||
"contain cards of diamonds" in {
|
||||
CardManager.cardContainer.count(_.suit == Suit.Diamonds) mustBe 13
|
||||
}
|
||||
"There are 13 cards of clubs" in {
|
||||
"contain 13 cards of clubs" in {
|
||||
CardManager.cardContainer.count(_.suit == Suit.Clubs) mustBe 13
|
||||
}
|
||||
"Check if shuffleAndReset shuffles the deck" in {
|
||||
"have cards in a different order after shuffling it" in {
|
||||
val originalDeck = List(CardManager.cardContainer)
|
||||
CardManager.shuffleAndReset()
|
||||
val shuffledDeck = CardManager.cardContainer
|
||||
shuffledDeck should not equal originalDeck
|
||||
}
|
||||
"Check if the nextCard method returns a card" in {
|
||||
"provide cards" in {
|
||||
val nextCard = CardManager.nextCard()
|
||||
nextCard should not be null
|
||||
}
|
||||
"Grab 2 cards from the deck" in {
|
||||
"provide different cards" in {
|
||||
val nextCard = CardManager.nextCard()
|
||||
val nextCard2 = CardManager.nextCard()
|
||||
nextCard should not equal nextCard2
|
||||
}
|
||||
"supply a hand of 7 cards" in {
|
||||
val hand = CardManager.createHand(7)
|
||||
hand.cards should have size 7
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user