コード例 #1
0
        public void HasValidCorrectAnswer_TextAnswer_Valid()
        {
            var question = new TestQuestion(1, "Q1", "A1", 2, QuestionType.TextAnswer);

            bool valid = questionValidator.HasValidCorrectAnswer(question);

            Assert.True(valid);
        }
コード例 #2
0
 /// <summary>
 /// check that all questions have valid values in <see cref="TestQuestion.CorrectAnswer"/> property
 /// <br/>
 /// if not, throw <see cref="ArgumentException"/>
 /// </summary>
 /// <param name="questions">questions to check</param>
 private void ThrowIfInvalidQuestion(IEnumerable <TestQuestion> questions)
 {
     if (questions.All(q => questionValidator.HasValidCorrectAnswer(q)))
     {
         return;
     }
     else
     {
         throw new ArgumentException("One of the questions has invalid value in property CorrectAnswer");
     }
 }