/// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="QuestionProvider"/> class.
 /// </summary>
 /// <param name="parsedQuestions">The parsed questions object.</param>
 /// <param name="manager">The PhrasePartManager that keeps track of all known key terms
 /// and all translatable parts in the project.</param>
 /// ------------------------------------------------------------------------------------
 public QuestionProvider(ParsedQuestions parsedQuestions, PhrasePartManager manager)
 {
     m_sections = parsedQuestions.Sections;
     m_manager  = manager;
 }
Пример #2
0
        public void EnumeratePhrases_EnsureSharedPartsAreHookedUpCorrectly()
        {
            ParsedQuestions pq = new ParsedQuestions();

            pq.KeyTerms = new [] {
                new KeyTermMatchSurrogate("luke", "lucas"),
                new KeyTermMatchSurrogate("jesus", "jesu"),
                new KeyTermMatchSurrogate("disciple", "dicipulo")
            };
            QuestionSections qs = pq.Sections = new QuestionSections();

            qs.Items = new Section[2];
            int iS = 0;

            qs.Items[iS] = MasterQuestionParserTests.CreateSection("ACT 1.1-5", "Acts 1:1-5 Introduction to the book.", 44001001,
                                                                   44001005, 2, 1);
            int      iC = 0;
            Question q  = qs.Items[iS].Categories[iC].Questions[0];

            q.Text = "What information did Luke give?";
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("what information did")));
            q.ParsedParts.Add(new ParsedPart(pq.KeyTerms[0]));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("give")));
            q      = qs.Items[iS].Categories[iC].Questions[1];
            q.Text = "What is a disciple of Jesus?";
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("what is a")));
            q.ParsedParts.Add(new ParsedPart(pq.KeyTerms[2]));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("of")));
            q.ParsedParts.Add(new ParsedPart(pq.KeyTerms[1]));

            iC     = 1;
            q      = qs.Items[iS].Categories[iC].Questions[0];
            q.Text = "What is a book?";
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("what is a")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("book")));

            iS           = 1;
            qs.Items[iS] = MasterQuestionParserTests.CreateSection("ACT 1.6-10", "Acts 1:6-10 The continuing saga.", 44001006, 44001010, 1, 2);
            iC           = 0;
            q            = qs.Items[iS].Categories[iC].Questions[0];
            q.Text       = "Which of the disciples wanted to give away land?";
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("which")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("of")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("the")));
            q.ParsedParts.Add(new ParsedPart(pq.KeyTerms[2]));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("wanted to")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("give")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("away land")));

            iC = 1;
            q  = qs.Items[iS].Categories[iC].Questions[0];
            q.ScriptureReference = "ACT 1.6";
            q.StartRef           = 44001006;
            q.EndRef             = 44001006;
            q.Text = "What information did jesus want to give the disciples?";
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("what information did")));
            q.ParsedParts.Add(new ParsedPart(pq.KeyTerms[1]));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("want to")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("give")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("the")));
            q.ParsedParts.Add(new ParsedPart(pq.KeyTerms[2]));

            q = qs.Items[iS].Categories[iC].Questions[1];
            q.ScriptureReference = "ACT 1.7";
            q.StartRef           = 44001007;
            q.EndRef             = 44001007;
            q.Text = "Do you want to read this book again?";
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("do you")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("want to")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("read this")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("book")));
            q.ParsedParts.Add(new ParsedPart(PhraseParser.GetWordsInString("again")));

            pq.TranslatableParts = new []
            {
                "what information did",
                "give",
                "what is a",
                "of",
                "book",
                "which",
                "the",
                "wanted to",
                "away land",
                "do you",
                "want to",
                "read this",
                "again"
            };
            QuestionProvider          qp      = new QuestionProvider(pq);
            List <TranslatablePhrase> phrases = qp.ToList();

            Assert.AreEqual(8, phrases.Count);

            TranslatablePhrase phrase = phrases[0];

            Assert.AreEqual("Overview", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "overview", 1);

            phrase = phrases[1];
            Assert.AreEqual("What information did Luke give?", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "what information did", 2, "give", 3);

            phrase = phrases[2];
            Assert.AreEqual("What is a disciple of Jesus?", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "what is a", 2, "of", 2);

            phrase = phrases[3];
            Assert.AreEqual("Details", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "details", 1);

            phrase = phrases[4];
            Assert.AreEqual("What is a book?", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "what is a", 2, "book", 2);

            phrase = phrases[5];
            Assert.AreEqual("Which of the disciples wanted to give away land?", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "which", 1, "of", 2, "the", 2, "wanted to", 1, "give", 3, "away land", 1);

            phrase = phrases[6];
            Assert.AreEqual("What information did jesus want to give the disciples?", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "what information did", 2, "want to", 2, "give", 3, "the", 2);

            phrase = phrases[7];
            Assert.AreEqual("Do you want to read this book again?", phrase.PhraseInUse);
            VerifyTranslatablePhrase(phrase, "do you", 1, "want to", 2, "read this", 1, "book", 2, "again", 1);
        }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="QuestionProvider"/> class. This version
 /// is only for testing.
 /// </summary>
 /// <param name="parsedQuestions">The parsed questions object.</param>
 /// ------------------------------------------------------------------------------------
 internal QuestionProvider(ParsedQuestions parsedQuestions)
 {
     m_sections = parsedQuestions.Sections;
     m_manager  = new PhrasePartManager(parsedQuestions.TranslatableParts, parsedQuestions.KeyTerms);
 }