public void Test_RoyalFlush_CreateInstance(string strCards, bool isValid) { var cards = Utils.ParseCards(strCards); var royalFlush = RoyalFlush.CreateInstance(cards); CreateInstanceHelper(royalFlush, HandRanks.RoyalFlush, cards, isValid); }
public void test_scores() { var highCard = new HighCard(); Assert.AreEqual(0, highCard.Score); var onePair = new OnePair(); Assert.AreEqual(1, onePair.Score); var twoPairs = new TwoPairs(); Assert.AreEqual(2, twoPairs.Score); var set = new Set(); Assert.AreEqual(3, set.Score); var straight = new Straight(); Assert.AreEqual(4, straight.Score); var flush = new Flush(); Assert.AreEqual(5, flush.Score); var fullHouse = new FullHouse(); Assert.AreEqual(6, fullHouse.Score); var quads = new Quads(); Assert.AreEqual(7, quads.Score); var straightFlush = new StraightFlush(); Assert.AreEqual(8, straightFlush.Score); var royalFlush = new RoyalFlush(); Assert.AreEqual(9, royalFlush.Score); }
public void Test_RoyalFlush_EqualityOperators(string strInputA, string strInputB, bool areEqual) { var cardsA = Utils.ParseCards(strInputA); var cardsB = Utils.ParseCards(strInputB); var royalFlushOne = RoyalFlush.CreateInstance(cardsA); var royalFlushTwo = RoyalFlush.CreateInstance(cardsB); EqualityOperatorsHelper(royalFlushOne, royalFlushTwo, areEqual); }
public void Test_RoyalFlush_ComparableTests(string royalFlushA, string royalFlushB, int comp) { var cardsA = Utils.ParseCards(royalFlushA); var cardsB = Utils.ParseCards(royalFlushB); var royalA = RoyalFlush.CreateInstance(cardsA); var royalB = RoyalFlush.CreateInstance(cardsB); ComparableTestsHelper(royalA, royalB, comp); }
public void Hearths() { // ARRANGE var game = Helper.HearthsRoyalFlush(); // ACT var result = new RoyalFlush().Evaluate(game); // ASSERT Assert.IsTrue(result.Success()); Assert.AreSame(game.Cards, result.UsedCards); }
public void NineInsteadOfTen() { var royalFlush = Helper.HearthsRoyalFlush(); var game = GameBuilder.Game(royalFlush).SwapLastCardWith( CardBuilder.Nine().Hearths()); // ACT var result = new RoyalFlush().Evaluate(game); // ASSERT Assert.IsFalse(result.Success()); }
public void Test_RoyalFlush_EqualityOperators_ForNull() { var cards = Utils.ParseCards("TH JH KH QH AH"); var royalflush = RoyalFlush.CreateInstance(cards); Assert.False(royalflush.Equals(null)); Assert.True((RoyalFlush)null == (RoyalFlush)null); Assert.False((RoyalFlush)null == royalflush); Assert.False(royalflush == (RoyalFlush)null); Assert.False((RoyalFlush)null != (RoyalFlush)null); Assert.True((RoyalFlush)null != royalflush); Assert.True(royalflush != (RoyalFlush)null); }
public void Spades() { // ARRANGE var hearthsRoyalFlushCards = Helper.HearthsRoyalFlush().Cards; var cards = hearthsRoyalFlushCards.Select( c => new Card(c.Rank, Suit.SPADES)).ToArray(); var game = new Game(cards[0], cards[1], cards[2], cards[3], cards[4]); // ACT var result = new RoyalFlush().Evaluate(game); // ASSERT Assert.IsTrue(result.Success()); Assert.AreSame(game.Cards, result.UsedCards); }
public void Diamonds() { // ARRANGE var hearthsRoyalFlushCards = Helper.HearthsRoyalFlush().Cards; var cards = hearthsRoyalFlushCards.Select( c => new Card(c.Rank, Suit.DIAMONDS)).ToArray(); var game = new Game(cards[0], cards[1], cards[2], cards[3], cards[4]); // ACT var result = new RoyalFlush().Evaluate(game); // ASSERT Assert.IsTrue(result.Success()); Assert.AreSame(game.Cards, result.UsedCards); }
public void royalflush_no3() { var set = new RoyalFlush(); var cards = new List <Card> { new Card(Suit.Clubs, Rank.Ace), new Card(Suit.Clubs, Rank.Seven), new Card(Suit.Clubs, Rank.King), new Card(Suit.Clubs, Rank.Ten), new Card(Suit.Clubs, Rank.Seven) }; set.SetCards(cards); var result = set.IsPresent(); Assert.IsFalse(result); }
public void royalflush_no1() { var set = new RoyalFlush(); var cards = new List <Card> { new Card(Suit.Spades, Rank.King), new Card(Suit.Spades, Rank.Jack), new Card(Suit.Diamonds, Rank.Queen), new Card(Suit.Spades, Rank.Ace), new Card(Suit.Spades, Rank.Ten), new Card(Suit.Diamonds, Rank.Six), new Card(Suit.Spades, Rank.Nine) }; set.SetCards(cards); var result = set.IsPresent(); Assert.IsFalse(result); }
public void royalflush_yes3() { var set = new RoyalFlush(); var cards = new List <Card>() { new Card(Suit.Spades, Rank.King), new Card(Suit.Diamonds, Rank.Ten), new Card(Suit.Hearts, Rank.Ace), new Card(Suit.Hearts, Rank.King), new Card(Suit.Hearts, Rank.Queen), new Card(Suit.Hearts, Rank.Jack), new Card(Suit.Hearts, Rank.Ten) }; set.SetCards(cards); var result = set.IsPresent(); Assert.IsTrue(result); }
private string GetScore(IPokerHand hand) { var royalFlush = new RoyalFlush(hand); if (royalFlush.IsHighRank) { return(royalFlush.Title); } var straightFlush = new StraightFlush(hand); if (straightFlush.IsHighRank) { return(straightFlush.Title); } var fourOfAKind = new FourOfAKind(hand); if (fourOfAKind.IsHighRank) { return(fourOfAKind.Title); } var fullHouse = new FullHouse(hand); if (fullHouse.IsHighRank) { return(fullHouse.Title); } var flush = new Flush(hand); if (flush.IsHighRank) { return(flush.Title); } var straight = new Straight(hand); if (straight.IsHighRank) { return(straight.Title); } var threeOfAKind = new ThreeOfAKind(hand); if (threeOfAKind.IsHighRank) { return(threeOfAKind.Title); } var twoPair = new TwoPair(hand); if (twoPair.IsHighRank) { return(twoPair.Title); } var onePair = new OnePair(hand); if (onePair.IsHighRank) { return(onePair.Title); } return("High Card"); }