public void PokerFaceMain_FileNotFound_ExitsEarly()
        {
            // Arrange
            _cardHandsFileReader.FileExists().Returns(false);
            var pokerFaceMain = new PokerFaceMain(_cardHandsFileReader, _pokerHandNamer);

            // Act
            var result = pokerFaceMain.EvaluateHands();

            // Assert
            Assert.AreEqual((int)Constants.ExitStatusCode.InputFileNotFound, result);
        }
Esempio n. 2
0
        public int EvaluateHands()
        {
            if (!_cardHandsFileReader.FileExists())
            {
                Console.WriteLine(Constants.ErrorMessageInputFileNotFound);
                return((int)Constants.ExitStatusCode.InputFileNotFound);
            }

            _cardHandsFileReader.OpenFile();
            while (!_cardHandsFileReader.AtEndOfFile())
            {
                var cardHandString = _cardHandsFileReader.ReadNextCardHandLine();
                var cardHand       = MapStringToCardHand.Map(cardHandString);

                if (cardHand != null)
                {
                    var pokerHandName = _pokerHandNamer.GetPokerHandNameForCardHand(cardHand);
                    Console.WriteLine($"{cardHandString} => {pokerHandName}");
                }
                else
                {
                    Console.WriteLine($"Error: Could not construct valid card hand from line: {cardHandString}");
                }
            }

            _cardHandsFileReader.CloseFile();
            return((int)Constants.ExitStatusCode.Success);
        }