コード例 #1
0
        /// <summary>
        /// Initializes category choosing.
        /// </summary>
        /// <param name="game">Instance of <see cref="HangmanGame"/> class.</param>
        public override void Play(HangmanGame game)
        {
            var contentReader = new FolderContentReader();
            string[] categoriesToList = contentReader.GetCategories(Globals.CategoriesPath, "*" + Globals.FileExtension);
            game.UI.Print(categoriesToList);
            game.UI.Print(Messages.EnterChoiceMessage, "NewLine");

            string chosenCategory = game.UI.ReadLine();

            bool categoryExists = this.CategoriesToLower(categoriesToList).Contains(chosenCategory.ToLower());

            if (categoryExists)
            {
                game.WordSelect.FileName = "../../Words/" + chosenCategory + Globals.FileExtension;
            }
            else
            {
                game.UI.Print(Messages.WrongCommand, "NewLine");

                this.Play(game);
            }

            game.State = new InitializeGameState();
            game.State.Play(game);
        }
コード例 #2
0
        /// <summary>
        /// Initializes category choosing.
        /// </summary>
        /// <param name="game">Instance of <see cref="HangmanGame"/> class.</param>
        public override void Play(HangmanGame game)
        {
            var contentReader = new FolderContentReader();

            string[] categoriesToList = contentReader.GetCategories(Globals.CategoriesPath, "*" + Globals.FileExtension);
            game.UI.Print(categoriesToList);
            game.UI.Print(Messages.EnterChoiceMessage, "NewLine");

            string chosenCategory = game.UI.ReadLine();

            bool categoryExists = this.CategoriesToLower(categoriesToList).Contains(chosenCategory.ToLower());

            if (categoryExists)
            {
                game.WordSelect.FileName = "../../Words/" + chosenCategory + Globals.FileExtension;
            }
            else
            {
                game.UI.Print(Messages.WrongCommand, "NewLine");

                this.Play(game);
            }

            game.State = new InitializeGameState();
            game.State.Play(game);
        }
コード例 #3
0
        public void ExpectToReturnCathegoriesWhenWrightPathIsProvided()
        {
            var contentReader  = new FolderContentReader();
            var categoriesList = contentReader.GetCategories(@"..\..\..\HQC.Project.Hangman2.1\bin" + Globals.CategoriesPath, "*" + Globals.FileExtension);

            string[] allCategories =
            {
                "Animals",      "CarManufacturers", "Countries",
                "EgyptianGods", "Fruits",           "GreekMythology",
                "IT",           "Philosophers",     "Random",        "Space", "Vegetables"
            };
            Assert.AreEqual(allCategories.Length, categoriesList.Length);

            for (int i = 0; i < allCategories.Length; i++)
            {
                Assert.IsTrue(allCategories[i].Contains(categoriesList[i]));
            }
        }
コード例 #4
0
        public void ExpectToReturnCathegoriesWhenWrightPathIsProvided()
        {
            var contentReader = new FolderContentReader();
            var categoriesList = contentReader.GetCategories(@"..\..\..\HQC.Project.Hangman2.1\bin" + Globals.CategoriesPath, "*" + Globals.FileExtension);

            string[] allCategories = 
                {
                    "Animals", "CarManufacturers", "Countries",
                    "EgyptianGods", "Fruits", "GreekMythology",
                    "IT", "Philosophers", "Random", "Space", "Vegetables"
                };
            Assert.AreEqual(allCategories.Length, categoriesList.Length);

            for (int i = 0; i < allCategories.Length; i++)
            {
                Assert.IsTrue(allCategories[i].Contains(categoriesList[i]));
            }
        }
コード例 #5
0
 public void ExpectToThrowWhenWrongPathToCathegoryListIsProvided()
 {
     var contentReader  = new FolderContentReader();
     var categoriesList = contentReader.GetCategories("wrong path" + Globals.CategoriesPath, "*" + Globals.FileExtension);
 }
コード例 #6
0
 public void ExpectToThrowWhenWrongPathToCathegoryListIsProvided()
 {
     var contentReader = new FolderContentReader();
     var categoriesList = contentReader.GetCategories("wrong path" + Globals.CategoriesPath, "*" + Globals.FileExtension);
 }