コード例 #1
0
        public void ProvideNegativeIndex()
        {
            var madLibsMenu = new MadLibsMenu();
            var madLib      = madLibsMenu.GetMadLib(Console.Out, new StringReader("-1"));

            Assert.IsNull(madLib, "Madlib was selected when none should have been selected.");
        }
コード例 #2
0
        public void ProvideTooLargeIndex()
        {
            var madLibsMenu = new MadLibsMenu();
            var madLib      = madLibsMenu.GetMadLib(
                Console.Out,
                new StringReader($"{madLibsMenu.MadLibs.Count + 2}"));

            Assert.IsNull(madLib, "Madlib was selected when none should have been selected.");
        }
コード例 #3
0
        public void SelectRandomMadlib()
        {
            var madLibsMenu = new MadLibsMenu();
            var madLib      = madLibsMenu.GetMadLib(
                Console.Out,
                new StringReader($"{madLibsMenu.MadLibs.Count + 1}"));

            Assert.IsNotNull(madLib, "No Madlib returned.");
        }
コード例 #4
0
ファイル: MadLibsGame.cs プロジェクト: sorensenmattj/Madlibs
        public void Play()
        {
            var    madLibsMenu = new MadLibsMenu();
            MadLib madLib      = null;

            while (madLib == null)
            {
                madLib = madLibsMenu.GetMadLib(Console.Out, Console.In);
            }

            madLib.GetUserAnswers(Console.Out, Console.In);
            madLib.Print(Console.Out);
        }
コード例 #5
0
        public void SelectMadlib()
        {
            var madLibsMenu = new MadLibsMenu();

            for (int i = 0; i < madLibsMenu.MadLibs.Count; i++)
            {
                var madLib = madLibsMenu.GetMadLib(Console.Out, new StringReader($"{i+1}"));

                Assert.AreEqual(
                    madLibsMenu.MadLibs[i].MadLibName,
                    madLib.MadLibName,
                    "Selected Madlib name does not match expected name.");
            }
        }
コード例 #6
0
        public void GiveAnswersToMadLib()
        {
            var madLibsMenu = new MadLibsMenu();
            var madLib      = madLibsMenu.GetMadLib(Console.Out, new StringReader("1"));

            var answersBuilder = new StringBuilder();

            for (int i = 1; i < 50; i++)
            {
                answersBuilder.Append($"{i}\n");
            }

            var answers = answersBuilder.ToString();

            madLib.GetUserAnswers(Console.Out, new StringReader(answers));
            madLib.Print(Console.Out);
        }