public void TestDeck() { Deck deck = new Deck(); deck = deck.generateDeck(); //Test to make sure all edge cases made it into the deck Assert.IsTrue(deck.Find('S', "9"), "Deck.GetCards failed for S9."); Assert.IsTrue(deck.Find('S', "A"), "Deck.GetCards failed for SA."); Assert.IsTrue(deck.Find('D', "9"), "Deck.GetCards failed for D9."); Assert.IsTrue(deck.Find('D', "A"), "Deck.GetCards failed for DA."); Assert.IsTrue(deck.Find('H', "9"), "Deck.GetCards failed for H9."); Assert.IsTrue(deck.Find('H', "A"), "Deck.GetCards failed for HA."); Assert.IsTrue(deck.Find('C', "9"), "Deck.GetCards failed for C9."); Assert.IsTrue(deck.Find('C', "A"), "Deck.GetCards failed for CA."); //Test to make sure the cards were evenly divided into hands. List<Hand> hands = deck.draw(); Assert.IsTrue(hands[0].Find('S', "9"), "Deck.Draw failed for S9."); Assert.IsTrue(hands[0].Find('C', "Q"), "Deck.Draw failed for SA."); Assert.IsTrue(hands[1].Find('S', "A"), "Deck.Draw failed for D9."); Assert.IsTrue(hands[1].Find('C', "K"), "Deck.Draw failed for DA."); Assert.IsTrue(hands[2].Find('H', "9"), "Deck.Draw failed for H9."); Assert.IsTrue(hands[2].Find('C', "10"), "Deck.Draw failed for HA."); Assert.IsTrue(hands[3].Find('H', "J"), "Deck.Draw failed for C9."); Assert.IsTrue(hands[3].Find('C', "A"), "Deck.Draw failed for CA."); }
public void TestDeckShuffle() { Deck d1 = new Deck(); d1 = d1.generateDeck(); List<Card> ld1 = d1.getCards(); Deck d2 = new Deck(); d2 = d2.generateDeck(); List<Card> ld2 = d2.getCards(); Assert.AreEqual(ld1[0].compare(ld2[0]), 0, "First index not euqal."); Assert.AreEqual(ld1[5].compare(ld2[5]), 0, "Fifth index not euqal."); Assert.AreEqual(ld1[11].compare(ld2[11]), 0, "Eleventh index not euqal."); Assert.AreEqual(ld1[17].compare(ld2[17]), 0, "Seventeenth index not euqal."); Assert.AreEqual(ld1[23].compare(ld2[23]), 0, "Twenty-third index not euqal."); d2.shuffle(); ld2 = d2.getCards(); int n = ld1.Count; int sum = 0; int acceptability = 15; for (int i=0; i<n; i++) { if (ld1[i].compare(ld2[i]) != 0) sum += 1; } Assert.IsTrue(sum >= acceptability, "Shuffled places below acceptability."); }
public void deal() { Deck deck = new Deck(); deck = deck.generateDeck(); deck.shuffle(); List<Hand> hands = deck.draw(); player.hand = hands[0]; cpu1.hand = hands[1]; cpu2.hand = hands[2]; cpu3.hand = hands[3]; }