Example #1
0
        public void ListingTheTerritoryAttributesInTheDatabaseShouldListThemAllAndShouldReturnTheListAsAgenericList()
        {
            // Arrange
            Mock <ITerritoryTable> mockDatabase = new Mock <ITerritoryTable>();

            mockDatabase.Setup(r => r.RetrieveNumberOfRowsInTable()).Returns(1);
            mockDatabase.Setup(r => r.TableName).Returns("Table Name");
            mockDatabase.Setup(r => r.RetrieveTableRow("Table Name", 1)).Returns("5\nBilly\nRed\nSugar");
            ITerritoryAdministration sut  = new TerritoryAdministration(territory, mockDatabase.Object);
            List <TriviaTerritory>   test = new List <TriviaTerritory>();

            // Act
            test = sut.ListTerritories();
            string index      = test[0].territoryIndex;
            string name       = test[0].userName;
            string color      = test[0].color;
            string playerTurn = test[0].playersTurn;

            // Assert
            Assert.AreEqual("5", index);
            Assert.AreEqual("Billy", name);
            Assert.AreEqual("Red", color);
        }
Example #2
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();
        }