CasinoGames/CasinoKit/Tests/CasinoKitTests/CasinoKitTests.swift
Matt Bruce 78f7cb1544 Reorganize repo: move git to root, add Blackjack and CasinoKit
- Move .git from Baccarat/ to CasinoGames root
- Add Blackjack game project
- Add CasinoKit shared framework
- Add .gitignore for Xcode/Swift projects
- Add Agents.md and GAME_TEMPLATE.md documentation
- Add CasinoGames.xcworkspace
2025-12-22 13:18:29 -06:00

125 lines
3.6 KiB
Swift

//
// CasinoKitTests.swift
// CasinoKit
//
// Unit tests for CasinoKit components.
//
import Testing
@testable import CasinoKit
@Suite("Card Tests")
struct CardTests {
@Test("Standard deck has 52 cards")
func standardDeckSize() {
let deck = Deck()
#expect(deck.cardsRemaining == 52)
}
@Test("Multi-deck shoe has correct count")
func multiDeckSize() {
let shoe = Deck(deckCount: 8)
#expect(shoe.cardsRemaining == 416)
}
@Test("Drawing reduces card count")
func drawingCards() {
var deck = Deck()
_ = deck.draw()
#expect(deck.cardsRemaining == 51)
_ = deck.draw(5)
#expect(deck.cardsRemaining == 46)
}
@Test("Reset restores all cards")
func resetDeck() {
var deck = Deck()
_ = deck.draw(20)
deck.reset()
#expect(deck.cardsRemaining == 52)
}
@Test("Card baccarat values are correct")
func baccaratValues() {
#expect(Rank.ace.baccaratValue == 1)
#expect(Rank.five.baccaratValue == 5)
#expect(Rank.ten.baccaratValue == 0)
#expect(Rank.king.baccaratValue == 0)
}
@Test("Card blackjack values are correct")
func blackjackValues() {
#expect(Rank.ace.blackjackValue == 11)
#expect(Rank.five.blackjackValue == 5)
#expect(Rank.ten.blackjackValue == 10)
#expect(Rank.king.blackjackValue == 10)
}
@Test("Card display format is correct")
func cardDisplay() {
let card = Card(suit: .hearts, rank: .ace)
#expect(card.display == "A♥")
let king = Card(suit: .spades, rank: .king)
#expect(king.display == "K♠")
}
}
@Suite("Chip Tests")
struct ChipTests {
@Test("Chip display text is correct")
func chipDisplayText() {
#expect(ChipDenomination.ten.displayText == "10")
#expect(ChipDenomination.hundred.displayText == "100")
#expect(ChipDenomination.thousand.displayText == "1K")
#expect(ChipDenomination.hundredThousand.displayText == "100K")
}
@Test("Chip unlock thresholds are correct")
func chipUnlockBalance() {
// Basic chips always available
#expect(ChipDenomination.ten.isUnlocked(forBalance: 0))
#expect(ChipDenomination.hundred.isUnlocked(forBalance: 0))
// Higher chips need balance
#expect(!ChipDenomination.fiveHundred.isUnlocked(forBalance: 100))
#expect(ChipDenomination.fiveHundred.isUnlocked(forBalance: 500))
}
@Test("Available chips filter correctly")
func availableChipsForBalance() {
let lowBalance = ChipDenomination.availableChips(forBalance: 100)
#expect(lowBalance.count == 4) // 10, 25, 50, 100
let highBalance = ChipDenomination.availableChips(forBalance: 100_000)
#expect(highBalance.count == 11) // All chips
}
}
@Suite("Theme Tests")
struct ThemeTests {
@Test("Default theme provides chip colors")
func defaultThemeChipColors() {
let theme = DefaultCasinoTheme()
let colors = theme.chipColors(for: .hundred)
#expect(colors.primary != colors.secondary)
}
@Test("All denominations have chip colors")
func allDenominationsHaveColors() {
let theme = DefaultCasinoTheme()
for denomination in ChipDenomination.allCases {
let colors = theme.chipColors(for: denomination)
// Just verify it doesn't crash and returns valid colors
#expect(colors.stripe.description.count > 0)
}
}
}