예제 #1
0
        public void NextStep_withDefaultParamShouldReturnModelWithInitValues()
        {
            var model = _service.NextStep();

            Assert.AreEqual(_modelInit.AnswearChars.Length, model.AnswearChars.Length);
            Assert.AreEqual(_modelInit.EnteredChars.Count, model.EnteredChars.Count);
            Assert.AreEqual(_modelInit.HangManStatus, model.HangManStatus);
            Assert.AreEqual(_modelInit.PlayerStatus, model.PlayerStatus);
        }
예제 #2
0
        public void StartApplication()
        {
            bool startNewGame = true;

            while (startNewGame)
            {
                Console.Clear();
                Console.WriteLine("Enter secret phrase to start game: ");
                var    secret  = Console.ReadLine();
                string entered = null;

                _service.SetSecret(secret);
                while (!_service.IsGameFinished())
                {
                    Console.Clear();
                    var model = _service.NextStep(String.IsNullOrEmpty(entered) ? null : entered[0]);
                    ConsoleDrawMan(model.HangManStatus);
                    ConsoleDrawData(model);
                    ConsoleDrawResult(model);
                    entered = Console.ReadLine();
                    if (IsSomeErrors(model))
                    {
                        break;
                    }
                }

                Console.WriteLine("Do you want to start over? Y/N _");
                var result = Console.ReadLine();
                startNewGame = result?.ToUpper() == "Y";
            }
        }