예제 #1
0
        public void NotAllowEmptyPokerHandList()
        {
            HandComparer sut = new HandComparer();
            //empty list
            var list = new List <PokerHandDto>();

            Assert.Throws <ArgumentException>(() => sut.GetWinningHand(list));
        }
예제 #2
0
        /// <summary>
        /// Gets the winning poker hands.
        /// </summary>
        /// <param name="pokerHandIds">The poker hand ids.</param>
        /// <returns>List of winning poker hands with provided ids. Can be more than one in case of a tie</returns>
        public IEnumerable <PokerHandDto> GetWinningPokerHands(IEnumerable <Guid> pokerHandIds)
        {
            List <PokerHandDto> handsToReturn = new List <PokerHandDto>();

            foreach (var pokerHandId in pokerHandIds)
            {
                handsToReturn.Add(GetPokerHand(pokerHandId));
            }
            handsToReturn = _handComparer.GetWinningHand(handsToReturn);
            return(handsToReturn);
        }
예제 #3
0
        public void GetWinningHand_SingleHand_PhilWins()
        {
            var testHandCalc = new HandComparer();
            var testPokHand1 = CreateTestPokerHandDto("Phil Hellmuth", "Straight Flush", "AH", "KH", "10H", "JH", "QH");

            string expectedWinnerName = "Phil Hellmuth";

            var pokerHandReturned = testHandCalc.GetWinningHand(new List <PokerHandDto> {
                testPokHand1
            });

            Assert.Single(pokerHandReturned);
            Assert.Equal(expectedWinnerName, pokerHandReturned.FirstOrDefault().PlayerName);
        }
예제 #4
0
        public void GetWinningHand_BoatVsBoat_PhilWins()
        {
            var testHandCalc = new HandComparer();
            var testPokHand1 = CreateTestPokerHandDto("Daniel Negranu", "Full House", "2D", "7H", "2H", "7D", "2D");
            var testPokHand2 = CreateTestPokerHandDto("Phil Hellmuth", "Full House", "KS", "9C", "KD", "9D", "KC");

            string expectedWinnerName1 = "Phil Hellmuth";

            var pokerHandReturned = testHandCalc.GetWinningHand(new List <PokerHandDto> {
                testPokHand1, testPokHand2
            });

            Assert.Single(pokerHandReturned);
            Assert.Equal(expectedWinnerName1, pokerHandReturned[0].PlayerName);
        }
예제 #5
0
        public void GetWinningHand_StraightFlushVsStraighFlushVsStraightFlushDifferent_PhilWins()
        {
            var testHandCalc = new HandComparer();
            var testPokHand1 = CreateTestPokerHandDto("Daniel Negranu", "Straight Flush", "2H", "6H", "3H", "4H", "5H");
            var testPokHand2 = CreateTestPokerHandDto("Phil Hellmuth", "Straight Flush", "AH", "KH", "10H", "JH", "QH");
            var testPokHand3 = CreateTestPokerHandDto("Tony G", "Straight Flush", "8D", "6D", "7D", "9D", "10D");

            string expectedWinnerName = "Phil Hellmuth";

            var pokerHandReturned = testHandCalc.GetWinningHand(new List <PokerHandDto> {
                testPokHand1, testPokHand2, testPokHand3
            });

            Assert.Single(pokerHandReturned);
            Assert.Equal(expectedWinnerName, pokerHandReturned.FirstOrDefault().PlayerName);
        }
예제 #6
0
        public void GetWinningHand_TwoPairVsTwoPairVsTwoPair_PhilWins()
        {
            var testHandCalc = new HandComparer();
            var testPokHand1 = CreateTestPokerHandDto("Tony G", "Two Pair", "2D", "7H", "2H", "7D", "5D");
            var testPokHand2 = CreateTestPokerHandDto("Phil Hellmuth", "Two Pair", "KD", "KH", "JH", "AC", "AH");
            var testPokHand3 = CreateTestPokerHandDto("Daniel Negranu", "Two Pair", "AD", "KS", "KC", "10D", "AC");

            string expectedWinnerName1 = "Phil Hellmuth";

            var pokerHandReturned = testHandCalc.GetWinningHand(new List <PokerHandDto> {
                testPokHand1, testPokHand2
            });

            Assert.Single(pokerHandReturned);
            Assert.Equal(expectedWinnerName1, pokerHandReturned[0].PlayerName);
        }
예제 #7
0
        public void GetWinningHand_HighCardVsHighCardVsHighCard_TonyWins()
        {
            var testHandCalc = new HandComparer();
            var testPokHand1 = CreateTestPokerHandDto("Daniel Negranu", "High Card", "2D", "7H", "6H", "QS", "4H");
            var testPokHand2 = CreateTestPokerHandDto("Phil Hellmuth", "High Card", "2S", "7C", "6S", "QD", "4C");
            var testPokHand3 = CreateTestPokerHandDto("Tony G", "High Card", "3H", "7D", "6D", "QC", "4S");


            string expectedWinnerName1 = "Tony G";

            var pokerHandReturned = testHandCalc.GetWinningHand(new List <PokerHandDto> {
                testPokHand1, testPokHand2, testPokHand3
            });

            Assert.Single(pokerHandReturned);
            Assert.Equal(expectedWinnerName1, pokerHandReturned.FirstOrDefault().PlayerName);
        }
예제 #8
0
        public void GetWinningHand_HighCardVsHighCardVsHighCard_TwoWayChopPhilAndTony()
        {
            var testHandCalc = new HandComparer();
            var testPokHand1 = CreateTestPokerHandDto("Daniel Negranu", "High Card", "2D", "7H", "6H", "10D", "4H");
            var testPokHand2 = CreateTestPokerHandDto("Phil Hellmuth", "High Card", "2S", "7C", "6S", "QD", "4C");
            var testPokHand3 = CreateTestPokerHandDto("Tony G", "High Card", "2H", "7D", "6D", "QC", "4S");

            string expectedWinnerName1 = "Phil Hellmuth";
            string expectedWinnerName2 = "Tony G";

            var pokerHandReturned = testHandCalc.GetWinningHand(new List <PokerHandDto> {
                testPokHand1, testPokHand2, testPokHand3
            });

            Assert.Equal(2, pokerHandReturned.Count());
            Assert.Equal(expectedWinnerName1, pokerHandReturned[0].PlayerName);
            Assert.Equal(expectedWinnerName2, pokerHandReturned[1].PlayerName);
        }
예제 #9
0
        public void NotAllowNullPokerHandList()
        {
            HandComparer sut = new HandComparer();

            Assert.Throws <ArgumentNullException>("hands", () => sut.GetWinningHand(null));
        }