示例#1
0
        //Got this by pasting into the quiz page when the Talking Book was open
        // This fails. Enable when fixing BL-5910

        /*[TestCase(@"<p><span id='b352ae2e-8394-4d6b-82a3-367521cbafb5' class='audio-sentence'>first <br></span>
         *                      <span id='b6376333-986a-4b23-91ea-31028e19da07' class='audio-sentence'>one <br></span>
         *                      <span id='i3636d82b-4d87-4b21-9a36-3b020a957abd' class='audio-sentence'>*two</span></p>
         *                      <p><span id='i7e03445c-1936-428d-8911-e829f55ae863' class='audio-sentence'>second <br></span>
         *                      <span id='i2b681f7e-a315-4584-8524-0f4809c3bf18' class='audio-sentence'>*aa <br></span>
         *                      <span id='i34524d36-0a96-4788-8131-991bd855bb77' class='audio-sentence'>bb <br> <br></span></p>")]
         */
        public void ExtractQuestionGroups_ParsesCorrectly(string contents)
        {
            contents = contents.Replace("<br>", "<br/>");             // convert from html to xml
            var page = new XmlDocument();

            page.LoadXml(@"<div><div class='bloom-editable' lang='abc'>" + contents + "</div></div>");
            var questionGroups = new List <QuestionGroup>();

            BloomReaderFileMaker.ExtractQuestionGroups(page.DocumentElement, questionGroups);
            Assert.AreEqual(1, questionGroups.Count);
            Assert.AreEqual(2, questionGroups[0].questions.Length);
            Assert.AreEqual("first", questionGroups[0].questions[0].question);
            Assert.AreEqual(2, questionGroups[0].questions[0].answers.Length);
            Assert.AreEqual("one", questionGroups[0].questions[0].answers[0].text);
            Assert.AreEqual("two", questionGroups[0].questions[0].answers[1].text);
            Assert.IsFalse(questionGroups[0].questions[0].answers[0].correct);
            Assert.IsTrue(questionGroups[0].questions[0].answers[1].correct);

            Assert.AreEqual("second", questionGroups[0].questions[1].question);
            Assert.AreEqual(2, questionGroups[0].questions[1].answers.Length);
            Assert.AreEqual("aa", questionGroups[0].questions[1].answers[0].text);
            Assert.AreEqual("bb", questionGroups[0].questions[1].answers[1].text);
            Assert.IsTrue(questionGroups[0].questions[1].answers[0].correct);
            Assert.IsFalse(questionGroups[0].questions[1].answers[1].correct);
        }
示例#2
0
        public void ExtractQuestionGroups_Long_ParsesCorrectly(string contents)
        {
            var page = new XmlDocument();

            page.LoadXml(@"<div><div class='bloom-editable' lang='abc'>" + contents + "</div></div>");
            var questionGroups = new List <QuestionGroup>();

            BloomReaderFileMaker.ExtractQuestionGroups(page.DocumentElement, questionGroups);
            Assert.AreEqual(1, questionGroups.Count);
            Assert.AreEqual(4, questionGroups[0].questions.Length);
        }