public void ShortAnswerQuestionAddTest2() { ShortAnswerQuestion q = new ShortAnswerQuestion(); // q.AddAnswer("true", "aucune", 50); q.AddAnswer("true", "aucune", 50); Action action = () => q.AddAnswer("true", "aucune", 50); Assert.ThrowsException <OverflowException>(action); // Trace.WriteLine(q.MoodleXML.OuterXml); }
/// <summary> /// Creates a short answer question. /// </summary> /// <param name="number">Question number</param> /// <param name="questionText">Question</param> /// <param name="answers">Answers to question (as strings)</param> /// <returns>Created <seealso cref="ShortAnswerQuestion"/> instance.</returns> public static ShortAnswerQuestion Build(int number, string questionText, IEnumerable <string> answers) { var question = new ShortAnswerQuestion(number, questionText) { Id = number }; foreach (var answer in answers) { question.AddAnswer(new ShortAnswer(answer)); } return(question); }
public void ShortAnswerQuestionAddTest() { ShortAnswerQuestion q = new ShortAnswerQuestion(); // q.AddAnswer("Réponse", "Feedback", 100); Assert.AreEqual(1, q.Answers.Count); // Answer shortAnswer = q.Answers[0]; Assert.AreEqual("Réponse", shortAnswer.Text); Assert.AreEqual("Feedback", shortAnswer.Feedback); Assert.AreEqual(100, shortAnswer.Fraction); }