public static void ClassInit(TestContext context) { _startingHandCombos = new Dictionary<string, WeightedStartingHandCombo>(); _startingHandPermutations = new Dictionary<string, WeightedStartingHandCombo>(); //All starting hands match a regular expression after ToString is called List<Card> cards = new List<Card>(); foreach (Rank r in (Rank[])Enum.GetValues(typeof(Rank))) { foreach (Suit s in (Suit[])Enum.GetValues(typeof(Suit))) { cards.Add(new Card(r, s)); } } for (int iFirstCard = 0; iFirstCard < 52; iFirstCard++) { for (int iSecondCard = iFirstCard + 1; iSecondCard < 52; iSecondCard++) { WeightedStartingHandCombo hand = new WeightedStartingHandCombo(cards[iFirstCard], cards[iSecondCard], 1); _startingHandCombos.Add(hand.ToString(false), hand); _startingHandPermutations.Add(hand.ToString(), hand); WeightedStartingHandCombo handOppOrder = new WeightedStartingHandCombo(cards[iSecondCard], cards[iFirstCard], 1); _startingHandPermutations.Add(handOppOrder.ToString(), handOppOrder); } } Assert.IsTrue(_startingHandCombos.Count == (52 * 51) / 2, "Incorrect number of combo's."); Assert.IsTrue(_startingHandPermutations.Count == 52 * 51, "Incorrect number of permutations."); }
/// <summary> /// Adds a combo to the range. If a combo already exists, it is overwritten (with a potentially new weight). If the combo is part of this starting hand, then a exception is thrown. /// </summary> /// <param name="combo">The combo to add.</param> public override void Add(WeightedStartingHandCombo combo) { if (combo.HighCard.Rank == this.HighRank && combo.LowCard.Rank == this.LowRank && combo.IsSuited() == this.IsSuited) { AddCombo(combo); } else { throw new ArgumentException("All combos of a StartingHand must have that same ranks and suitedness:" + _combos[0].ToString(true, true) + "!=" + combo.ToString(true, true)); } }
public void ToString_IncludesWeight_Passes() { Assert.AreEqual("AcKh(0.333)", new WeightedStartingHandCombo("AcKh", .333).ToString()); Assert.AreEqual("AcKh", new WeightedStartingHandCombo("AcKh", 1).ToString()); WeightedStartingHandCombo testDecimals = new WeightedStartingHandCombo("3c2h", .333); Assert.AreEqual(testDecimals.ToString(), new WeightedStartingHandCombo(testDecimals.ToString()).ToString()); string hand = "AcKh(0.333)"; Assert.AreEqual(hand, new WeightedStartingHandCombo(new WeightedStartingHandCombo("AcKh", .333).ToString()).ToString()); }
public void ToStringOverloads_FormatingWorksAsExpected_Passes() { WeightedStartingHandCombo hand = new WeightedStartingHandCombo("KhQd", .5); Assert.IsTrue(hand.ToString(true) == "KQo(0.5)"); Assert.IsTrue(new WeightedStartingHandCombo("QhKh", .5).ToString(true, true) == "KQs(0.5)"); }