import Testing
@testable import SoliCards

@Suite("Deck Tests")
struct DeckTests {

    @Test("Standard deck has 52 cards")
    func standardDeckCount() {
        let deck = Deck.standard()
        #expect(deck.count == 52)
    }

    @Test("Double deck has 104 cards")
    func doubleDeckCount() {
        let deck = Deck.double()
        #expect(deck.count == 104)
    }

    @Test("Standard deck has all suits and ranks")
    func standardDeckCompleteness() {
        let deck = Deck.standard()
        for suit in Suit.allCases {
            for rank in Rank.allCases {
                let count = deck.filter { $0.suit == suit && $0.rank == rank }.count
                #expect(count == 1, "Expected exactly 1 \(rank.displayName) of \(suit.displayName)")
            }
        }
    }

    @Test("Deck starts with all cards face down")
    func allFaceDown() {
        let deck = Deck.standard()
        #expect(deck.allSatisfy { !$0.isFaceUp })
    }

    @Test("Shuffle produces different orderings")
    func shuffleRandomness() {
        let deck1 = Deck.standard()
        let deck2 = Deck.standard()
        // Extremely unlikely to be identical after shuffle
        let sameOrder = zip(deck1, deck2).allSatisfy { $0.suit == $1.suit && $0.rank == $1.rank }
        #expect(!sameOrder)
    }
}
