コード例 #1
0
        public void FullHousesAreDiscriminatedCorrectly()
        {
            var sevensAndTensFull = new List <Card>
            {
                new Card(Suit.Clubs, 7),
                new Card(Suit.Diamonds, 7),
                new Card(Suit.Clubs, 7),
                new Card(Suit.Hearts, 10),
                new Card(Suit.Spades, 10),
            };

            var eightsAndNinesFull = new List <Card>
            {
                new Card(Suit.Clubs, 8),
                new Card(Suit.Diamonds, 8),
                new Card(Suit.Clubs, 8),
                new Card(Suit.Hearts, 9),
                new Card(Suit.Spades, 9)
            };

            var discriminatorFactory = new DiscriminatorFactory();
            var discriminator        = discriminatorFactory.CreateDiscriminator(HandType.FullHouse);

            var result = discriminator.GetWinnerForHandsWithSameType(sevensAndTensFull, eightsAndNinesFull);

            Assert.AreEqual(Winner.Second, result);
        }
コード例 #2
0
        public void CompareEqualDiscriminatesOnePairHands()
        {
            var firstHand = new List <Card>
            {
                new Card(Suit.Hearts, 2),
                new Card(Suit.Clubs, 2),
                new Card(Suit.Diamonds, 1),
                new Card(Suit.Clubs, 3),
                new Card(Suit.Spades, 12),
            };

            var secondHand = new List <Card>
            {
                new Card(Suit.Diamonds, 3),
                new Card(Suit.Hearts, 3),
                new Card(Suit.Clubs, 1),
                new Card(Suit.Spades, 7),
                new Card(Suit.Clubs, 9),
            };

            var discriminatorFactory = new DiscriminatorFactory();
            var discriminator        = discriminatorFactory.CreateDiscriminator(HandType.OnePair);

            var result = discriminator.GetWinnerForHandsWithSameType(firstHand, secondHand);

            Assert.AreEqual(Winner.Second, result);
        }
コード例 #3
0
        public void StraightsAreDiscriminatedCorrectly()
        {
            var straightTo8Hand = new List <Card>
            {
                new Card(Suit.Clubs, 4),
                new Card(Suit.Diamonds, 5),
                new Card(Suit.Clubs, 6),
                new Card(Suit.Hearts, 7),
                new Card(Suit.Spades, 8),
            };

            var straightTo7Hand = new List <Card>
            {
                new Card(Suit.Clubs, 3),
                new Card(Suit.Diamonds, 4),
                new Card(Suit.Clubs, 5),
                new Card(Suit.Hearts, 6),
                new Card(Suit.Spades, 7)
            };

            var discriminatorFactory = new DiscriminatorFactory();
            var discriminator        = discriminatorFactory.CreateDiscriminator(HandType.Straight);

            var result = discriminator.GetWinnerForHandsWithSameType(straightTo8Hand, straightTo7Hand);

            Assert.AreEqual(Winner.First, result);
        }