/// <summary> /// sets the questions information /// </summary> public void setQuestionInfo() { question = trivia.GetRandomQuestion(); Question = question.Question; Answer = question.Answer; PointValue = question.PointValue; }
public void AquiringARandomQuestionShouldReturnARandomTableRowFromDatabaseAndExtractOnlyTheQuestionFromTheRow() { // Arrange Mock <IDataBaseTable> mockDatabase = new Mock <IDataBaseTable>(); mockDatabase.Setup(r => r.RetrieveNumberOfRowsInTable()).Returns(5); mockDatabase.Setup(r => r.TableName).Returns("Table Name"); mockDatabase.Setup(r => r.RetrieveTableRow("Table Name", 1)).Returns("This is the first row.\n And this is its answer\n Question Type"); mockDatabase.Setup(r => r.RetrieveTableRow("Table Name", 2)).Returns("This is the second row.\n And this is its answer\n Question Type"); mockDatabase.Setup(r => r.RetrieveTableRow("Table Name", 3)).Returns("This is the third row.\n And this is its answer\n Question Type"); mockDatabase.Setup(r => r.RetrieveTableRow("Table Name", 4)).Returns("This is the fourth row.\n And this is its answer\n Question Type"); mockDatabase.Setup(r => r.RetrieveTableRow("Table Name", 5)).Returns("This is the fifth row.\n And this is its answer\n Question Type"); sut = new Trivia(mockDatabase.Object, question); int i = 0; // Act while (i <= 5) { IQuestion test = sut.GetRandomQuestion(); // Assert if (test.Question.Equals("This is the first row.")) { Assert.AreEqual("This is the first row.", test.Question); } else if (test.Question.Equals("This is the second row.")) { Assert.AreEqual("This is the second row.", test.Question); } else if (test.Question.Equals("This is the third row.")) { Assert.AreEqual("This is the third row.", test.Question); } else if (test.Question.Equals("This is the fourth row.")) { Assert.AreEqual("This is the fourth row.", test.Question); } else if (test.Question.Equals("This is the fifth row.")) { Assert.AreEqual("This is the fifth row.", test.Question); } else { Assert.Fail(); } i++; } }