Exemple #1
0
    public void test_e_is_shuffled() // Checks to see if cards are shuffled
    {
        //Creates 2 decks old and new, will be the same cards one will be shuffled and one will not

        // This will not change
        var unshuffledDeck = CardStackFunctions.GetCardStackMock();
        // This will be shuffled
        var shuffledDeck = CardStackFunctions.GetCardStackMock();

        CardStackFunctions.FillWithCards(unshuffledDeck, 52);
        CardStackFunctions.FillWithCards(shuffledDeck, 52);

        shuffledDeck.Shuffle(); // Shuffles only one deck

        int notEqualCount = 0;

        for (int i = 0; i < 52; i++)
        {
            int unshuffledCard = unshuffledDeck.Draw(0);
            int shuffledCard   = shuffledDeck.Draw(0);
            if (unshuffledCard != shuffledCard)
            {
                notEqualCount++;
            }
        }
        Assert.That(notEqualCount, Is.GreaterThan(30));
    }
    private Chance GetChanceMock()
    {
        var chance = Substitute.For <Chance>();

        chance.player = CardStackFunctions.GetCardStackMock();
        chance.dealer = CardStackFunctions.GetCardStackMock();
        chance.deck   = CardStackFunctions.GetCardStackMock();
        chance.deck.Start();

        //chance.soundClips = Substitute.For<AudioManager>();
        //chance.soundClips.sounds = new Sounds[3];
        //chance.soundClips.sounds =

        chance.playAgainButton = Substitute.For <Button>();
        chance.winnerText      = Substitute.For <Text>();
        chance.playerScore     = Substitute.For <Text>();
        chance.dealerScore     = Substitute.For <Text>();
        chance.playerHandScore = Substitute.For <Text>();
        chance.dealerHandScore = Substitute.For <Text>();
        chance.endTurnButton   = Substitute.For <Button>();
        chance.swapCardButton  = Substitute.For <Button>();
        chance.nextRoundButton = Substitute.For <Button>();

        chance.Start();

        return(chance);
    }
Exemple #3
0
    public void test_b_deck_holds_one_card()  // Check if it can store 1 card
    {
        var deck = CardStackFunctions.GetCardStackMock();

        deck.push(0);
        Assert.That(deck.CardCount, Is.EqualTo(1));
    }
Exemple #4
0
    public void test_d_deck_holds_52_cards()   // Check if it can hold a maximum of 52 cards
    {
        var deck = CardStackFunctions.GetCardStackMock();

        CardStackFunctions.FillWithCards(deck, 52);    // Fill it with 52 cards
        Assert.That(deck.CardCount, Is.EqualTo(52));
    }
    private Blackjack GetBlackJackMock() //Simulates BlackJack
    {
        var blackJack = Substitute.For <Blackjack>();

        blackJack.dealer = CardStackFunctions.GetCardStackMock();
        blackJack.player = CardStackFunctions.GetCardStackMock();
        blackJack.deck   = CardStackFunctions.GetCardStackMock();
        CardStackFunctions.FillWithCards(blackJack.deck, 52);


        // new text test
        blackJack.gameOverText    = Substitute.For <Text>();
        blackJack.winnerText      = Substitute.For <Text>();
        blackJack.playerScore     = Substitute.For <Text>();
        blackJack.dealerScore     = Substitute.For <Text>();
        blackJack.playerHandScore = Substitute.For <Text>();
        blackJack.dealerHandScore = Substitute.For <Text>();

        // it is unused in blackjack
        //blackJack.endTurnButton = Substitute.For<Button>();
        blackJack.hitButton       = Substitute.For <Button>();
        blackJack.nextRoundButton = Substitute.For <Button>();
        blackJack.playAgainButton = Substitute.For <Button>();
        blackJack.standButton     = Substitute.For <Button>();

        blackJack.Start();

        return(blackJack);
    }
Exemple #6
0
    public void test_c_deck_holds_draws_card_correctly()   // Check if it can hold and draw 1 random card
    {
        var deck = CardStackFunctions.GetCardStackMock();

        System.Random r          = new System.Random(); // Create a random number generator
        var           randomCard = r.Next(0, 52);       // Generate a random card between 0 to 51

        deck.push(randomCard);                          // Push it onto the deck
        Assert.That(deck.Draw(0), Is.EqualTo(randomCard));
    }
    public void test_d_draw_determined()
    {
        var dealer = CardStackFunctions.GetCardStackMock();
        var player = CardStackFunctions.GetCardStackMock();

        dealer.push(10);                                                                 // Jack of Clubs
        dealer.push(11);                                                                 // Queen of Clubs

        player.push(23);                                                                 // Jack of Diamonds
        player.push(24);                                                                 // Queen of Diamonds

        Assert.That(player.BlackjackSumValue(), Is.EqualTo(dealer.BlackjackSumValue())); // Assert  that player will tie with dealer
    }
    public void test_c_player_lose()
    {
        var dealer = CardStackFunctions.GetCardStackMock();
        var player = CardStackFunctions.GetCardStackMock();

        dealer.push(13);                                                                  // Ace of Diamonds
        dealer.push(14);                                                                  // 2 of Diamonds

        player.push(1);                                                                   // 2 of Clubs
        player.push(2);                                                                   // 3 of Clubs

        Assert.That(player.BlackjackSumValue(), Is.LessThan(dealer.BlackjackSumValue())); // Assert  that player will lose
    }
Exemple #9
0
    public void test_a_empty_deck_created()  // Check if empty deck with 0 cards can be created
    {
        var deck = CardStackFunctions.GetCardStackMock();

        Assert.AreEqual(deck.CardCount, 0);
    }