Пример #1
0
        public void SettingATestTerritoryUserNameShouldReturnTerritoryUserName()
        {
            // Arrange
            ITriviaTerritory terr = new TriviaTerritory();

            {
                // Act
                terr.userName = "******";
            };
            // Assert
            Assert.AreEqual("Josh", terr.userName);
        }
Пример #2
0
        public void SettingATerritoryIndexShouldReturnIndex()
        {
            // Arrange
            ITriviaTerritory terr = new TriviaTerritory();

            {
                // Act
                terr.territoryIndex = "5F";
            };
            // Assert
            Assert.AreEqual("5F", terr.territoryIndex);
        }
Пример #3
0
        public void SettingATestColorShouldReturnColor()
        {
            // Arrange
            ITriviaTerritory terr = new TriviaTerritory();

            {
                // Act
                terr.color = "red";
            };
            // Assert
            Assert.AreEqual("red", terr.color);
        }
        /// <summary>
        /// retreives a list of all the territories
        /// </summary>
        /// <returns></returns>
        public List <TriviaTerritory> ListTerritories()
        {
            List <TriviaTerritory> territories = new List <TriviaTerritory>();
            string listOfTerritories           = "";

            string[] test;

            for (int i = 1; i <= _database.RetrieveNumberOfRowsInTable(); i++)
            {
                TriviaTerritory territory = new TriviaTerritory();
                listOfTerritories = _database.RetrieveTableRow(_database.TableName, i);

                test = listOfTerritories.Split('\n');

                territory.territoryIndex = test[0];
                territory.userName       = test[1];
                territory.color          = test[2];
                territory.playersTurn    = test[3];

                territories.Add(territory);
            }

            return(territories);
        }
Пример #5
0
        static void Main(string[] args)
        {
            //connect to the DB
            new DataBaseOperations();
            DataBaseOperations.ConnectToDB();
            ITriviaAdministration triviaAdmin = new TriviaAdministration();

            //COMMENTED OUT CODE IS USED IF ALL THE TABLES ARE NEEDED TO BE
            //RECREATED AND REPOPULATED IN CASE OF CHANGES WHILE DEBUGGING

            /*
             * //creates a new QuestionPackTable to populate with QuestionPacks
             * QuestionPackTable questionPackTable = new QuestionPackTable();
             * questionPackTable.CreateTable(questionPackTable.TableName, questionPackTable.TableCreationString);
             * //set up selection, creation or deletion of QuestionPacks
             * ITriviaAdministration triviaAdmin = new TriviaAdministration(); // comment out triviaAdmin above if you need to use this
             * //Create 3 QuestionPacks
             * IQuestionPack qp1 = triviaAdmin.AddQuestionPack("questionPack1", 5);
             * IQuestionPack qp2 = triviaAdmin.AddQuestionPack("questionPack2", 10);
             * IQuestionPack qp3 = triviaAdmin.AddQuestionPack("questionPack3", 20);
             * //populate questionPacks
             * qp1.AddQuestion("Is this questionPack1, q1?", "yes~no~maybe~blue~yes", "MC");
             * qp1.AddQuestion("Is this questionPack1, q2?", "no~yes~maybe~blue~yes", "MC");
             * qp1.AddQuestion("Is this questionPack1, q3?", "maybe~no~yes~blue~yes", "MC");
             * qp1.AddQuestion("Is this questionPack1, q4?", "blue~no~maybe~yes~yes", "MC");
             * qp1.AddQuestion("Is this questionPack1, q5?", "5~4~3~6~5", "MC");
             * qp1.AddQuestion("Is this questionPack1, q6?", "q4~q6~maybe~blue~q6", "MC");
             * qp1.AddQuestion("Is this questionPack1, q7?", "yes~no~maybe~blue~yes", "MC");
             * qp1.AddQuestion("Is this questionPack1, q8?", "YES~NO~MAYBE~BLUE~YES", "MC");
             * qp1.AddQuestion("Is this questionPack1, q9?", "red~purple~fox~yes~yes", "MC");
             * qp1.AddQuestion("Is this questionPack1, q10?", "Yes~No~Maybe~Blue~Yes", "MC");
             *
             * qp2.AddQuestion("Is this questionPack2, q1?", "yes~no~maybe~blue~yes", "MC");
             * qp2.AddQuestion("Is this questionPack2, q2?", "no~yes~maybe~blue~yes", "MC");
             * qp2.AddQuestion("Is this questionPack2, q3?", "maybe~no~yes~blue~yes", "MC");
             * qp2.AddQuestion("Is this questionPack2, q4?", "blue~no~maybe~yes~yes", "MC");
             * qp2.AddQuestion("Is this questionPack2, q5?", "5~4~3~6~5", "MC");
             * qp2.AddQuestion("Is this questionPack2, q6?", "q4~q6~maybe~blue~q6", "MC");
             * qp2.AddQuestion("Is this questionPack2, q7?", "yes~no~maybe~blue~yes", "MC");
             * qp2.AddQuestion("Is this questionPack2, q8?", "YES~NO~MAYBE~BLUE~YES", "MC");
             * qp2.AddQuestion("Is this questionPack2, q9?", "red~purple~fox~yes~yes", "MC");
             *
             * qp3.AddQuestion("Is this questionPack3, q1?", "yes~no~maybe~blue~yes", "MC");
             * qp3.AddQuestion("Is this questionPack3, q2?", "no~yes~maybe~blue~yes", "MC");
             * qp3.AddQuestion("Is this questionPack3, q3?", "maybe~no~yes~blue~yes", "MC");
             * qp3.AddQuestion("Is this questionPack3, q4?", "blue~no~maybe~yes~yes", "MC");
             * qp3.AddQuestion("Is this questionPack3, q5?", "5~4~3~6~5", "MC");
             * qp3.AddQuestion("Is this questionPack3, q6?", "q4~q6~maybe~blue~q6", "MC");
             * qp3.AddQuestion("Is this questionPack3, q7?", "yes~no~maybe~blue~yes", "MC");
             * qp3.AddQuestion("Is this questionPack3, q8?", "YES~NO~MAYBE~BLUE~YES", "MC");
             * qp3.AddQuestion("Is this questionPack3, q9?", "red~purple~fox~yes~yes", "MC");
             */

            //This section of code was for testing the listing of QuestionPacks, QuestionPack
            //Questions, and deleting QuestionPacks

            /*
             * //list all QuestionPacks
             * IEnumerable<IQuestionPack> qpList = triviaAdmin.ListQuestionPacks();
             * foreach (IQuestionPack qp in qpList)
             * {
             *  Console.WriteLine(qp.QuestionPackName);
             *  Console.WriteLine(qp.PointValue);
             *  Console.WriteLine();
             * }
             *
             * //list all the Questions in qp1
             * IQuestionPack qp1 = triviaAdmin.RetrieveQuestionPackByName("questionPack1");
             * if (qp1 != null)
             * {
             *  for (int i = 0; i < qp1.QuestionPackQuestions.Count; i++)
             *  {
             *      Console.WriteLine(qp1.QuestionPackQuestions[i].Question);
             *      Console.WriteLine(qp1.QuestionPackQuestions[i].Answer);
             *      Console.WriteLine(qp1.QuestionPackQuestions[i].QuestionType);
             *      Console.WriteLine(qp1.QuestionPackQuestions[i].PointValue);
             *      Console.WriteLine(qp1.QuestionPackQuestions[i].QuestionPack);
             *      Console.WriteLine();
             *  }
             * }
             *
             * //list all the Questions in qp2
             * IQuestionPack qp2 = triviaAdmin.RetrieveQuestionPackByName("questionPack2");
             * if (qp2 != null)
             * {
             *  for (int i = 0; i < qp2.QuestionPackQuestions.Count; i++)
             *  {
             *      Console.WriteLine(qp2.QuestionPackQuestions[i].Question);
             *      Console.WriteLine(qp2.QuestionPackQuestions[i].Answer);
             *      Console.WriteLine(qp2.QuestionPackQuestions[i].QuestionType);
             *      Console.WriteLine(qp2.QuestionPackQuestions[i].PointValue);
             *      Console.WriteLine(qp2.QuestionPackQuestions[i].QuestionPack);
             *      Console.WriteLine();
             *  }
             * }
             *
             * //list all the Questions in qp3
             * IQuestionPack qp3 = triviaAdmin.RetrieveQuestionPackByName("questionPack3");
             * if (qp3 != null)
             * {
             *  for (int i = 0; i < qp3.QuestionPackQuestions.Count; i++)
             *  {
             *      Console.WriteLine(qp3.QuestionPackQuestions[i].Question);
             *      Console.WriteLine(qp3.QuestionPackQuestions[i].Answer);
             *      Console.WriteLine(qp3.QuestionPackQuestions[i].QuestionType);
             *      Console.WriteLine(qp3.QuestionPackQuestions[i].PointValue);
             *      Console.WriteLine(qp3.QuestionPackQuestions[i].QuestionPack);
             *      Console.WriteLine();
             *  }
             * }
             *
             * triviaAdmin.DeleteQuestionPack("questionPack3");
             * //list all QuestionPacks
             * IEnumerable<IQuestionPack> qpList1 = triviaAdmin.ListQuestionPacks();
             * foreach (IQuestionPack qp in qpList1)
             * {
             *  Console.WriteLine(qp.QuestionPackName);
             *  Console.WriteLine(qp.PointValue);
             *  Console.WriteLine();
             * }
             *
             * //list all the Questions in qp3
             * IQuestionPack qp4 = triviaAdmin.RetrieveQuestionPackByName("questionPack3");
             * if (qp4 != null)
             * {
             *  for (int i = 0; i < qp4.QuestionPackQuestions.Count; i++)
             *  {
             *      Console.WriteLine(qp4.QuestionPackQuestions[i].Question);
             *      Console.WriteLine(qp4.QuestionPackQuestions[i].Answer);
             *      Console.WriteLine(qp4.QuestionPackQuestions[i].QuestionType);
             *      Console.WriteLine(qp4.QuestionPackQuestions[i].PointValue);
             *      Console.WriteLine(qp4.QuestionPackQuestions[i].QuestionPack);
             *      Console.WriteLine();
             *  }
             * }
             */

            //This block of code was for testing the retrieval of random questions
            //IQuestionPack qp2 = triviaAdmin.RetrieveQuestionPackByName("questionPack2");
            //ITrivia trivia = new Trivia(qp2);

            //Console.WriteLine(trivia.GetRandomQuestion().Question);
            //Console.WriteLine(trivia.GetRandomQuestion().Question);
            //Console.WriteLine(trivia.GetRandomQuestion().Question);
            //Console.WriteLine(trivia.GetRandomQuestion().Question);
            ITerritoryTable          table = new TerritoryTable();
            ITriviaTerritory         terr  = new TriviaTerritory();
            ITerritoryAdministration admin = new TerritoryAdministration(terr, table);

            admin.DisableTurn(admin.ListTerritories(), "Mossy");
            //admin.CheckForTurn("Mossy");
            string a = "";
            //Console.ReadKey();
        }