コード例 #1
0
ファイル: ScoreboardTest.cs プロジェクト: qodetest/Projects
        public void TestAddPlayerToScoreboard()
        {
            Scoreboard scoreboard = new Scoreboard();
            string userInput = String.Empty + Environment.NewLine + "Ivan";
            StringReader reader = new StringReader(userInput);
            StringBuilder sb = new StringBuilder();
            StringWriter writer = new StringWriter(sb);
            Console.SetIn(reader);
            Console.SetOut(writer);
            scoreboard.AddPlayerToScoreboard(3);

            string expected = "Please enter your name for the top scoreboard: " + 
                               Environment.NewLine +
                              "Your name for the scoreboard should" +
                              " consists from at least 1 symblol! Try again!" +
                              Environment.NewLine +
                              "Please enter your name for the top scoreboard: ";
            string actual = sb.ToString();          
            reader.Close();
            writer.Close();
            
            Assert.AreEqual<string>(expected, actual,
                                    "There was an error in adding a new player to the scoreboard!");
        }