public DictionaryPage() { InitializeComponent(); SetBackButtonBehaviour(); settings = new PageSettings("Dictionary"); questionProvider = new QuestionProvider(settings); }
private void QuizImplementator() { if (questionProvider != null) { QuestionProvider.DeleteProvider(); } QuestionProvider.Reps = System.Convert.ToInt32(textBox_repNumber.Text); QuestionProvider.RepsWrong = System.Convert.ToInt32(textBox_repWrongNumber.Text); QuestionProvider.FileURL = fileUrl; questionProvider = QuestionProvider.GetInstance(); }
// METODY POMOCNICZE private void initialization() { questionProvider = QuestionProvider.GetInstance(); beginingQuestionsCount = questionProvider.questionsCount(); if (questionProvider.questionsCount() <= 0) { MessageBox.Show("Pleas load file with correct content"); } else { quizLogicService = new QuizLogic(); actualQuestion = questionProvider.getQuestion(rnd.Next(questionProvider.questionsCount() - 1)); fillContent(actualQuestion); } }
public void GivenZeroQuestionsPerCategory_WheAskingQuestion_Throws(string category) { var generatorMock = new Mock <IQuestionService>(); generatorMock.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>() }, { QuestionCategory.Rock, new Queue <string>() }, { QuestionCategory.Science, new Queue <string>() }, { QuestionCategory.Sports, new Queue <string>() } }); var provider = new QuestionProvider(generatorMock.Object); Assert.Throws <InvalidOperationException>(() => provider.GetQuestion(category)); }
public void GivenOneQuestionPerCategory_WhenAskingQuestion_CorrectQuestionIsReturned(string category) { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports" }) } }); var provider = new QuestionProvider(generator.Object); var question = provider.GetQuestion(category); Assert.That(question, Is.EqualTo("Q" + category)); }
public void GivenOneQuestionPerCategory_WhenAskingQuestion_QuestionContainerIsEmptied(string category) { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports" }) } }); var provider = new QuestionProvider(generator.Object); provider.GetQuestion(category); Assert.That(provider.GetQuestionCount(category), Is.Zero); }
public void GivenZeroQuestionsPerCategory_WhenQueryingCount_ReturnsZero(string category) { var generatorMock = new Mock <IQuestionService>(); generatorMock.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>() }, { QuestionCategory.Rock, new Queue <string>() }, { QuestionCategory.Science, new Queue <string>() }, { QuestionCategory.Sports, new Queue <string>() } }); var provider = new QuestionProvider(generatorMock.Object); var count = provider.GetQuestionCount(category); Assert.That(count, Is.Zero); }
public void GivenMultipleQuestionsPerCategory_AfterAskingQuestion_QuestionContainerDecreasesInSizeWithOne() { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop1", "QPop2", "QPop3" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports" }) } }); var provider = new QuestionProvider(generator.Object); provider.GetQuestion(QuestionCategory.Pop); Assert.That(provider.GetQuestionCount(QuestionCategory.Pop), Is.EqualTo(2)); }
public void GivenVariableQuestionsPerCategory_WhenQueryingCount_ReturnsCorrectValue() { var generator = new Mock <IQuestionService>(); generator.Setup(g => g.Get()).Returns( new Dictionary <string, Queue <string> > { { QuestionCategory.Pop, new Queue <string>(new[] { "QPop1", "QPop2", "QPop3" }) }, { QuestionCategory.Rock, new Queue <string>(new[] { "QRock1", "QRock2", "QRock3", "QRock4" }) }, { QuestionCategory.Science, new Queue <string>(new[] { "QScience1" }) }, { QuestionCategory.Sports, new Queue <string>(new[] { "QSports1", "QSports2" }) } }); var provider = new QuestionProvider(generator.Object); Assert.That(provider.GetQuestionCount(QuestionCategory.Pop), Is.EqualTo(3)); Assert.That(provider.GetQuestionCount(QuestionCategory.Rock), Is.EqualTo(4)); Assert.That(provider.GetQuestionCount(QuestionCategory.Science), Is.EqualTo(1)); Assert.That(provider.GetQuestionCount(QuestionCategory.Sports), Is.EqualTo(2)); }
public void AddedPhrases_InsertAfterAdditionAfterInsertionBefore() { List<PhraseCustomization> customizations = new List<PhraseCustomization>(); PhraseCustomization pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "Base question"; pc.ModifiedPhrase = "AAA"; pc.Type = PhraseCustomization.CustomizationType.InsertionBefore; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "AAA"; pc.ModifiedPhrase = "CCC"; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "CCC"; pc.ModifiedPhrase = "BBB"; pc.Type = PhraseCustomization.CustomizationType.InsertionBefore; customizations.Add(pc); QuestionSections qs = new QuestionSections(); qs.Items = new Section[1]; qs.Items[0] = CreateSection("ACT 1.1-6", "Acts 1:1-6 Introduction to the book.", 44001001, 44001006, 0, 1); Question q = qs.Items[0].Categories[1].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "Base question"; QuestionProvider qp = new QuestionProvider(qs, customizations); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(6, phrases.Count); TranslatablePhrase phrase = phrases[2]; Assert.AreEqual("AAA", phrase.PhraseInUse); Assert.GreaterOrEqual(phrase.SequenceNumber, 0); Assert.Less(phrase.SequenceNumber, phrases[3].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[4].QuestionInfo, phrase.AddedPhraseAfter); phrase = phrases[3]; Assert.AreEqual("BBB", phrase.PhraseInUse); Assert.Less(phrase.SequenceNumber, phrases[4].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); phrase = phrases[4]; Assert.AreEqual("CCC", phrase.PhraseInUse); Assert.Less(phrase.SequenceNumber, phrases[5].SequenceNumber); Assert.AreEqual(phrases[3].QuestionInfo, phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); phrase = phrases[5]; Assert.AreEqual("Base question", phrase.PhraseInUse); Assert.AreEqual(phrases[2].QuestionInfo, phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); }
public void AddedPhrases_AddAfterInsertionBefore() { List<PhraseCustomization> customizations = new List<PhraseCustomization>(); PhraseCustomization pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "What question did the apostles ask Jesus about his kingdom?"; pc.ModifiedPhrase = "Is this question before the one about the meaning of apostle?"; pc.Type = PhraseCustomization.CustomizationType.InsertionBefore; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "Is this question before the one about the meaning of apostle?"; pc.ModifiedPhrase = "This is a phrase after the inserted question."; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); QuestionSections qs = new QuestionSections(); qs.Items = new Section[1]; qs.Items[0] = CreateSection("ACT 1.1-6", "Acts 1:1-6 Introduction to the book.", 44001001, 44001006, 0, 1); Question q = qs.Items[0].Categories[1].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "What question did the apostles ask Jesus about his kingdom?"; q.Answers = new[] { "Stuff." }; QuestionProvider qp = new QuestionProvider(qs, customizations); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(5, phrases.Count); TranslatablePhrase phrase = phrases[2]; Assert.AreEqual("Is this question before the one about the meaning of apostle?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.GreaterOrEqual(phrase.SequenceNumber, 0); Assert.Less(phrase.SequenceNumber, phrases[3].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[3].QuestionInfo, phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo.Answers); phrase = phrases[3]; Assert.AreEqual("This is a phrase after the inserted question.", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.Less(phrase.SequenceNumber, phrases[4].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo.Answers); phrase = phrases[4]; Assert.AreEqual("What question did the apostles ask Jesus about his kingdom?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.AreEqual(phrases[2].QuestionInfo, phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("Stuff.", phrase.QuestionInfo.Answers.ElementAt(0)); }
public void AddedPhrases_Compound() { List<PhraseCustomization> customizations = new List<PhraseCustomization>(); PhraseCustomization pc = new PhraseCustomization(); pc.Reference = "ACT 1.1-5"; pc.OriginalPhrase = "What do you think an apostle of Jesus is?"; pc.ModifiedPhrase = "Is this question before the one about the meaning of apostle?"; pc.Answer = "Yup"; pc.Type = PhraseCustomization.CustomizationType.InsertionBefore; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "What question did the apostles ask Jesus about his kingdom?"; pc.ModifiedPhrase = "What did He answer?"; pc.Answer = "He told them to mind their own business."; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.1-5"; pc.OriginalPhrase = "Is this question before the one about the meaning of apostle?"; pc.ModifiedPhrase = "Is this question before the one before the one about the meaning of apostle?"; pc.Type = PhraseCustomization.CustomizationType.InsertionBefore; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.1-5"; pc.OriginalPhrase = "Is this question before the one about the meaning of apostle?"; pc.ModifiedPhrase = "This is going to hurt, isn't it?"; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "What did He answer?"; pc.ModifiedPhrase = "I said, what did He answer?"; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "I said, what did He answer?"; pc.ModifiedPhrase = "Can I just go home now?"; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); QuestionSections qs = new QuestionSections(); qs.Items = new Section[2]; int iS = 0; qs.Items[iS] = 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, the writer of this book, give in this introduction?"; q.Answers = new[] { "Luke reminded his readers that he was about to continue the true story about Jesus" }; q = qs.Items[iS].Categories[iC].Questions[1]; q.Text = "What do you think an apostle of Jesus is?"; q.Answers = new[] { "Key Term Check: To be an apostle of Jesus means to be a messenger" }; iC = 1; q = qs.Items[iS].Categories[iC].Questions[0]; q.Text = "To whom did the writer of Acts address this book?"; q.Answers = new[] { "He addressed this book to Theophilus." }; iS = 1; qs.Items[iS] = CreateSection("ACT 1.6-10", "Acts 1:6-10 The continuing saga.", 44001006, 44001010, 1, 1); iC = 0; q = qs.Items[iS].Categories[iC].Questions[0]; q.Text = "What happened?"; q.Answers = new[] { "Stuff" }; iC = 1; q = qs.Items[iS].Categories[iC].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "What question did the apostles ask Jesus about his kingdom?"; q.Answers = new[] { "The apostles asked Jesus whether he was soon going to set up his kingdom in a way that everybody could see and cause the people of Israel to have power in that kingdom." }; QuestionProvider qp = new QuestionProvider(qs, customizations); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(13, phrases.Count); Assert.AreEqual(1, qp.AvailableBookIds.Length); Assert.AreEqual(44, qp.AvailableBookIds[0]); Assert.AreEqual(2, qp.SectionHeads.Count); Assert.AreEqual("Acts 1:1-5 Introduction to the book.", qp.SectionHeads["ACT 1.1-5"]); Assert.AreEqual("Acts 1:6-10 The continuing saga.", qp.SectionHeads["ACT 1.6-10"]); TranslatablePhrase phrase = phrases[0]; Assert.AreEqual("Overview", phrase.PhraseInUse); Assert.AreEqual(-1, phrase.Category); Assert.AreEqual(string.Empty, phrase.Reference); Assert.AreEqual(001001001, phrase.StartRef); Assert.AreEqual(066022021, phrase.EndRef); Assert.AreEqual(0, phrase.SequenceNumber); Assert.IsNull(phrase.QuestionInfo); phrase = phrases[1]; Assert.AreEqual("What information did Luke, the writer of this book, give in this introduction?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.Greater(phrase.SequenceNumber, 0); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("Luke reminded his readers that he was about to continue the true story about Jesus", phrase.QuestionInfo.Answers.First()); phrase = phrases[2]; Assert.AreEqual("Is this question before the one before the one about the meaning of apostle?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.Less(phrases[1].SequenceNumber, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo.Answers); phrase = phrases[3]; Assert.AreEqual("Is this question before the one about the meaning of apostle?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.Less(phrases[2].SequenceNumber, phrase.SequenceNumber); Assert.AreEqual(phrases[2].QuestionInfo, phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[4].QuestionInfo, phrase.AddedPhraseAfter); Assert.AreEqual("Yup", phrase.QuestionInfo.Answers.First()); phrase = phrases[4]; Assert.AreEqual("This is going to hurt, isn't it?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.Less(phrases[3].SequenceNumber, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo.Answers); phrase = phrases[5]; Assert.AreEqual("What do you think an apostle of Jesus is?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.Less(phrases[4].SequenceNumber, phrase.SequenceNumber); Assert.AreEqual("Is this question before the one about the meaning of apostle?", phrase.InsertedPhraseBefore.Text); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("Key Term Check: To be an apostle of Jesus means to be a messenger", phrase.QuestionInfo.Answers.ElementAt(0)); phrase = phrases[6]; Assert.AreEqual("Details", phrase.PhraseInUse); Assert.AreEqual(-1, phrase.Category); Assert.AreEqual(string.Empty, phrase.Reference); Assert.AreEqual(001001001, phrase.StartRef); Assert.AreEqual(066022021, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo); phrase = phrases[7]; Assert.AreEqual("To whom did the writer of Acts address this book?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("He addressed this book to Theophilus.", phrase.QuestionInfo.Answers.First()); phrase = phrases[8]; Assert.AreEqual("What happened?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.6-10", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001010, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("Stuff", phrase.QuestionInfo.Answers.First()); phrase = phrases[9]; Assert.AreEqual("What question did the apostles ask Jesus about his kingdom?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.Greater(phrase.SequenceNumber, 0); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[10].QuestionInfo, phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("The apostles asked Jesus whether he was soon going to set up his kingdom in a way that everybody could see and cause the people of Israel to have power in that kingdom.", phrase.QuestionInfo.Answers.First()); phrase = phrases[10]; Assert.AreEqual("What did He answer?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.Less(phrases[9].SequenceNumber, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[11].QuestionInfo, phrase.AddedPhraseAfter); Assert.AreEqual("He told them to mind their own business.", phrase.QuestionInfo.Answers.First()); phrase = phrases[11]; Assert.AreEqual("I said, what did He answer?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.Less(phrases[10].SequenceNumber, phrase.SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[12].QuestionInfo, phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo.Answers); phrase = phrases[12]; Assert.AreEqual("Can I just go home now?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.Less(phrases[11].SequenceNumber, phrase.SequenceNumber); Assert.IsNull(phrase.QuestionInfo.Answers); }
public void EnumeratePhrases_Basic() { QuestionSections qs = new QuestionSections(); qs.Items = new Section[2]; int iS= 0; qs.Items[iS] = 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, the writer of this book, give in this introduction?"; q.Answers = new [] { "Luke reminded his readers that he was about to continue the true story about Jesus" }; q = qs.Items[iS].Categories[iC].Questions[1]; q.Text = "What do you think an apostle of Jesus is?"; q.Answers = new [] { "Key Term Check: To be an apostle of Jesus means to be a messenger", "Can also be translated as \"sent one\"" }; q.Notes = new [] {"Note: apostles can be real sweethearts sometimes"}; iC = 1; q = qs.Items[iS].Categories[iC].Questions[0]; q.Text = "To whom did the writer of Acts address this book?"; q.Answers = new [] { "He addressed this book to Theophilus." }; iS= 1; qs.Items[iS] = CreateSection("ACT 1.6-10", "Acts 1:6-10 The continuing saga.", 44001006, 44001010, 1, 1); iC = 0; q = qs.Items[iS].Categories[iC].Questions[0]; q.Text = "What happened?"; q.Answers = new [] { "Stuff" }; iC = 1; q = qs.Items[iS].Categories[iC].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "What question did the apostles ask Jesus about his kingdom?"; q.Answers = new [] { "The apostles asked Jesus whether he was soon going to set up his kingdom in a way that everybody could see and cause the people of Israel to have power in that kingdom." }; QuestionProvider qp = new QuestionProvider(qs, null); Assert.AreEqual(2, qp.SectionHeads.Count); Assert.AreEqual("Acts 1:1-5 Introduction to the book.", qp.SectionHeads["ACT 1.1-5"]); Assert.AreEqual("Acts 1:6-10 The continuing saga.", qp.SectionHeads["ACT 1.6-10"]); Assert.AreEqual(1, qp.AvailableBookIds.Length); Assert.AreEqual(44, qp.AvailableBookIds[0]); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(7, phrases.Count); TranslatablePhrase phrase = phrases[0]; Assert.AreEqual("Overview", phrase.PhraseInUse); Assert.AreEqual(-1, phrase.Category); Assert.AreEqual(string.Empty, phrase.Reference); Assert.AreEqual(001001001, phrase.StartRef); Assert.AreEqual(066022021, phrase.EndRef); Assert.AreEqual(0, phrase.SequenceNumber); Assert.IsNull(phrase.QuestionInfo); phrase = phrases[1]; Assert.AreEqual("What information did Luke, the writer of this book, give in this introduction?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.IsNull(phrase.QuestionInfo.Notes); Assert.AreEqual("Luke reminded his readers that he was about to continue the true story about Jesus", phrase.QuestionInfo.Answers.First()); phrase = phrases[2]; Assert.AreEqual("What do you think an apostle of Jesus is?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.AreEqual(phrases[1].SequenceNumber + 1, phrase.SequenceNumber); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(2, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual(1, phrase.QuestionInfo.Notes.Count()); Assert.AreEqual("Key Term Check: To be an apostle of Jesus means to be a messenger", phrase.QuestionInfo.Answers.ElementAt(0)); Assert.AreEqual("Can also be translated as \"sent one\"", phrase.QuestionInfo.Answers.ElementAt(1)); Assert.AreEqual("Note: apostles can be real sweethearts sometimes", phrase.QuestionInfo.Notes.ElementAt(0)); phrase = phrases[3]; Assert.AreEqual("Details", phrase.PhraseInUse); Assert.AreEqual(-1, phrase.Category); Assert.AreEqual(string.Empty, phrase.Reference); Assert.AreEqual(001001001, phrase.StartRef); Assert.AreEqual(066022021, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNull(phrase.QuestionInfo); phrase = phrases[4]; Assert.AreEqual("To whom did the writer of Acts address this book?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.1-5", phrase.Reference); Assert.AreEqual(44001001, phrase.StartRef); Assert.AreEqual(44001005, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.IsNull(phrase.QuestionInfo.Notes); Assert.AreEqual("He addressed this book to Theophilus.", phrase.QuestionInfo.Answers.First()); phrase = phrases[5]; Assert.AreEqual("What happened?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ACT 1.6-10", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001010, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.IsNull(phrase.QuestionInfo.Notes); Assert.AreEqual("Stuff", phrase.QuestionInfo.Answers.First()); phrase = phrases[6]; Assert.AreEqual("What question did the apostles ask Jesus about his kingdom?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.IsNull(phrase.QuestionInfo.Notes); Assert.AreEqual("The apostles asked Jesus whether he was soon going to set up his kingdom in a way that everybody could see and cause the people of Israel to have power in that kingdom.", phrase.QuestionInfo.Answers.First()); }
public void ExcludePhrases() { List<PhraseCustomization> customizations = new List<PhraseCustomization>(); PhraseCustomization pc = new PhraseCustomization(); pc.Reference = "ACT 1.1-5"; pc.OriginalPhrase = "What do you think an apostle of Jesus is?"; pc.Type = PhraseCustomization.CustomizationType.Deletion; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "What question did the apostles ask Jesus about his kingdom?"; pc.Type = PhraseCustomization.CustomizationType.Deletion; customizations.Add(pc); QuestionSections qs = new QuestionSections(); qs.Items = new Section[2]; int iS = 0; qs.Items[iS] = 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, the writer of this book, give in this introduction?"; q.Answers = new[] { "Luke reminded his readers that he was about to continue the true story about Jesus" }; q = qs.Items[iS].Categories[iC].Questions[1]; q.Text = "What do you think an apostle of Jesus is?"; q.Answers = new[] { "Key Term Check: To be an apostle of Jesus means to be a messenger"}; iC = 1; q = qs.Items[iS].Categories[iC].Questions[0]; q.Text = "To whom did the writer of Acts address this book?"; q.Answers = new[] { "He addressed this book to Theophilus." }; iS = 1; qs.Items[iS] = CreateSection("ACT 1.6-10", "Acts 1:6-10 The continuing saga.", 44001006, 44001010, 1, 1); iC = 0; q = qs.Items[iS].Categories[iC].Questions[0]; q.Text = "What happened?"; q.Answers = new[] { "Stuff" }; iC = 1; q = qs.Items[iS].Categories[iC].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "What question did the apostles ask Jesus about his kingdom?"; q.Answers = new[] { "The apostles asked Jesus whether he was soon going to set up his kingdom in a way that everybody could see and cause the people of Israel to have power in that kingdom." }; QuestionProvider qp = new QuestionProvider(qs, customizations); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(7, phrases.Count); Assert.AreEqual(1, qp.AvailableBookIds.Length); Assert.AreEqual(44, qp.AvailableBookIds[0]); Assert.AreEqual(2, qp.SectionHeads.Count); Assert.AreEqual("Acts 1:1-5 Introduction to the book.", qp.SectionHeads["ACT 1.1-5"]); Assert.AreEqual("Acts 1:6-10 The continuing saga.", qp.SectionHeads["ACT 1.6-10"]); TranslatablePhrase phrase = phrases[0]; Assert.AreEqual("Overview", phrase.PhraseInUse); Assert.IsFalse(phrase.IsExcluded); phrase = phrases[1]; Assert.AreEqual("What information did Luke, the writer of this book, give in this introduction?", phrase.PhraseInUse); Assert.IsFalse(phrase.IsExcluded); phrase = phrases[2]; Assert.AreEqual("What do you think an apostle of Jesus is?", phrase.PhraseInUse); Assert.IsTrue(phrase.IsExcluded); phrase = phrases[3]; Assert.AreEqual("Details", phrase.PhraseInUse); Assert.IsFalse(phrase.IsExcluded); phrase = phrases[4]; Assert.AreEqual("To whom did the writer of Acts address this book?", phrase.PhraseInUse); Assert.IsFalse(phrase.IsExcluded); phrase = phrases[5]; Assert.AreEqual("What happened?", phrase.PhraseInUse); Assert.IsFalse(phrase.IsExcluded); phrase = phrases[6]; Assert.AreEqual("What question did the apostles ask Jesus about his kingdom?", phrase.PhraseInUse); Assert.IsTrue(phrase.IsExcluded); }
public void EnumeratePhrases_UnnamedCategory() { QuestionSections qs = new QuestionSections(); qs.Items = new Section[1]; int iS= 0; Section s = new Section(); qs.Items[iS] = s; s.ScriptureReference = "ROM 1.1-17"; s.Heading = "Romans 1:1-17 Introduction to the book."; s.StartRef = 45001001; s.EndRef = 45001017; s.Categories = new Category[1]; s.Categories[0] = new Category(); s.Categories[0].Questions = new Question[1]; Question q = s.Categories[0].Questions[0] = new Question(); q.Text = "Who wrote this book?"; q.Answers = new[] { "Paul." }; QuestionProvider qp = new QuestionProvider(qs, null); Assert.AreEqual(1, qp.SectionHeads.Count); Assert.AreEqual("Romans 1:1-17 Introduction to the book.", qp.SectionHeads["ROM 1.1-17"]); Assert.AreEqual(1, qp.AvailableBookIds.Length); Assert.AreEqual(45, qp.AvailableBookIds[0]); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(1, phrases.Count); TranslatablePhrase phrase = phrases[0]; Assert.AreEqual("Who wrote this book?", phrase.PhraseInUse); Assert.AreEqual(0, phrase.Category); Assert.AreEqual("ROM 1.1-17", phrase.Reference); Assert.AreEqual(45001001, phrase.StartRef); Assert.AreEqual(45001017, phrase.EndRef); Assert.AreEqual(1, phrase.SequenceNumber); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.IsNull(phrase.QuestionInfo.Notes); Assert.AreEqual("Paul.", phrase.QuestionInfo.Answers.First()); }
public void AddedPhrases_AddQuestionWithoutEnglishVersion() { List<PhraseCustomization> customizations = new List<PhraseCustomization>(); PhraseCustomization pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "What question did the apostles ask Jesus about his kingdom?"; Guid guidOfAddedQuestion = Guid.NewGuid(); pc.ModifiedPhrase = Question.kGuidPrefix + guidOfAddedQuestion; pc.Type = PhraseCustomization.CustomizationType.InsertionBefore; customizations.Add(pc); QuestionSections qs = new QuestionSections(); qs.Items = new Section[1]; qs.Items[0] = CreateSection("ACT 1.1-6", "Acts 1:1-6 Introduction to the book.", 44001001, 44001006, 0, 1); Question q = qs.Items[0].Categories[1].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "What question did the apostles ask Jesus about his kingdom?"; q.Answers = new[] { "Stuff." }; QuestionProvider qp = new QuestionProvider(qs, customizations); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(4, phrases.Count); TranslatablePhrase phrase = phrases[2]; Assert.AreEqual(string.Empty, phrase.PhraseInUse); Assert.AreEqual("User-added question with no English version", phrase.PhraseToDisplayInUI); Assert.AreEqual(Question.kGuidPrefix + guidOfAddedQuestion, phrase.PhraseKey.Text); Assert.AreEqual(string.Empty, phrase.OriginalPhrase); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.GreaterOrEqual(phrase.SequenceNumber, 0); Assert.Less(phrase.SequenceNumber, phrases[3].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNull(phrase.QuestionInfo.Answers); phrase = phrases[3]; Assert.AreEqual("What question did the apostles ask Jesus about his kingdom?", phrase.PhraseInUse); Assert.AreEqual(1, phrase.Category); Assert.AreEqual("ACT 1.6", phrase.Reference); Assert.AreEqual(44001006, phrase.StartRef); Assert.AreEqual(44001006, phrase.EndRef); Assert.AreEqual(phrases[2].QuestionInfo, phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); Assert.IsNotNull(phrase.QuestionInfo); Assert.AreEqual(1, phrase.QuestionInfo.Answers.Count()); Assert.AreEqual("Stuff.", phrase.QuestionInfo.Answers.ElementAt(0)); }
public void AddedPhrases_InsertAfterPhraseWithoutEnglishVersion() { List<PhraseCustomization> customizations = new List<PhraseCustomization>(); PhraseCustomization pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = "Base question"; Guid guidOfAddedQuestion = Guid.NewGuid(); pc.ModifiedPhrase = Question.kGuidPrefix + guidOfAddedQuestion; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); pc = new PhraseCustomization(); pc.Reference = "ACT 1.6"; pc.OriginalPhrase = Question.kGuidPrefix + guidOfAddedQuestion; pc.ModifiedPhrase = "Is this English, or what?"; pc.Type = PhraseCustomization.CustomizationType.AdditionAfter; customizations.Add(pc); QuestionSections qs = new QuestionSections(); qs.Items = new Section[1]; qs.Items[0] = CreateSection("ACT 1.1-6", "Acts 1:1-6 Introduction to the book.", 44001001, 44001006, 0, 1); Question q = qs.Items[0].Categories[1].Questions[0]; q.ScriptureReference = "ACT 1.6"; q.StartRef = 44001006; q.EndRef = 44001006; q.Text = "Base question"; QuestionProvider qp = new QuestionProvider(qs, customizations); List<TranslatablePhrase> phrases = qp.ToList(); Assert.AreEqual(5, phrases.Count); TranslatablePhrase phrase = phrases[2]; Assert.AreEqual("Base question", phrase.PhraseInUse); Assert.Less(phrase.SequenceNumber, phrases[3].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[3].QuestionInfo, phrase.AddedPhraseAfter); phrase = phrases[3]; Assert.AreEqual("User-added question with no English version", phrase.PhraseToDisplayInUI); Assert.AreEqual(Question.kGuidPrefix + guidOfAddedQuestion, phrase.PhraseKey.Text); Assert.AreEqual(string.Empty, phrase.OriginalPhrase); Assert.Less(phrase.SequenceNumber, phrases[4].SequenceNumber); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.AreEqual(phrases[4].QuestionInfo, phrase.AddedPhraseAfter); phrase = phrases[4]; Assert.AreEqual("Is this English, or what?", phrase.PhraseInUse); Assert.IsNull(phrase.InsertedPhraseBefore); Assert.IsNull(phrase.AddedPhraseAfter); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the translations. /// </summary> /// ------------------------------------------------------------------------------------ private void LoadTranslations(TxlSplashScreen splashScreen) { if (splashScreen != null) splashScreen.Message = Properties.Resources.kstidSplashMsgLoadingQuestions; Exception e; KeyTermRules rules = XmlSerializationHelper.DeserializeFromFile<KeyTermRules>(m_keyTermRulesFilename, out e); if (e != null) MessageBox.Show(e.ToString(), Text); List<PhraseCustomization> customizations = null; if (File.Exists(m_phraseCustomizationsFile)) { customizations = XmlSerializationHelper.DeserializeFromFile<List<PhraseCustomization>>(m_phraseCustomizationsFile, out e); if (e != null) MessageBox.Show(e.ToString()); } QuestionProvider qp = new QuestionProvider(m_questionsFilename, customizations); m_helper = new PhraseTranslationHelper(qp, m_keyTerms, rules, m_phraseSubstitutions); m_helper.KeyTermRenderingRulesFile = Path.Combine(s_unsDataFolder, string.Format("Term rendering selection rules - {0}.xml", m_projectName)); m_sectionHeadText = qp.SectionHeads; m_availableBookIds = qp.AvailableBookIds; if (File.Exists(m_translationsFile)) { if (splashScreen != null) splashScreen.Message = Properties.Resources.kstidSplashMsgLoadingTranslations; List<XmlTranslation> translations = XmlSerializationHelper.DeserializeFromFile<List<XmlTranslation>>(m_translationsFile, out e); if (e != null) MessageBox.Show(e.ToString()); else { foreach (XmlTranslation unsTranslation in translations) { TranslatablePhrase phrase = m_helper.GetPhrase(unsTranslation.Reference, unsTranslation.PhraseKey); if (phrase != null && !phrase.IsExcluded) phrase.Translation = unsTranslation.Translation; } } } m_helper.ProcessAllTranslations(); m_helper.TranslationsChanged += m_helper_TranslationsChanged; dataGridUns.RowCount = m_helper.Phrases.Count(); }