public void GetPhrasesSortedByOriginalPhrase()
		{
			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] {
				new TranslatablePhrase(new TestQ("What would God have me to say with respect to Paul?", "A", 1, 1), 1, 0),
				new TranslatablePhrase(new TestQ("What is Paul asking me to say with respect to that dog?", "B", 2, 2), 1, 0),
				new TranslatablePhrase(new TestQ("that dog", "C", 3, 3), 1, 0),
				new TranslatablePhrase(new TestQ("Is it okay for Paul me to talk with respect to God today?", "D", 4, 4), 1, 0),
				new TranslatablePhrase(new TestQ("that dog wishes this Paul and what is say radish", "E", 5, 5), 1, 0),
				new TranslatablePhrase(new TestQ("What is that dog?", "F", 6, 6), 1, 0)},
				m_dummyKtList, m_keyTermRules, new List<Substitution>());

			pth.Sort(PhraseTranslationHelper.SortBy.EnglishPhrase, true);

			Assert.AreEqual("D", pth[0].Reference);
			Assert.AreEqual("C", pth[1].Reference);
			Assert.AreEqual("E", pth[2].Reference);
			Assert.AreEqual("B", pth[3].Reference);
			Assert.AreEqual("F", pth[4].Reference);
			Assert.AreEqual("A", pth[5].Reference);

			pth.Sort(PhraseTranslationHelper.SortBy.EnglishPhrase, false);

			Assert.AreEqual("A", pth[0].Reference);
			Assert.AreEqual("F", pth[1].Reference);
			Assert.AreEqual("B", pth[2].Reference);
			Assert.AreEqual("E", pth[3].Reference);
			Assert.AreEqual("C", pth[4].Reference);
			Assert.AreEqual("D", pth[5].Reference);
		}
		public void GetPhrasesFilteredTextually_PartialMatchWithoutRenderings()
		{
			AddMockedKeyTerm("God", 1, 4);
			AddMockedKeyTerm("Paul", 1, 2, 5);
			AddMockedKeyTerm("have", 1, 2, 3, 4, 5, 6);
			AddMockedKeyTerm("say", null, 1, 2, 5);

			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] {
				new TranslatablePhrase(new TestQ("This would God have me to say with respect to Paul?", "A", 1, 1), 1, 0),       // what would (1)     | me to (3)       | with respect to (3)
				new TranslatablePhrase(new TestQ("What is Paul asking me to say with respect to that dog?", "B", 2, 2), 1, 0),   // what is (3)        | asking (1)      | me to (3)           | with respect to (3) | that dog (4)
				new TranslatablePhrase(new TestQ("that dog", "C", 3, 3), 1, 0),                                                  // that dog (4)
				new TranslatablePhrase(new TestQ("Is it okay for Paul me to talk with respect to God today?", "D", 4, 4), 1, 0), // is it okay for (1) | me to (3)       | talk (1)            | with respect to (3) | today (1)
				new TranslatablePhrase(new TestQ("that dog wishes this Paul and what is say radish", "E", 5, 5), 1, 0),          // that dog (4)       | wishes this (1) | and (1)             | what is (3)         | radish (1)
				new TranslatablePhrase(new TestQ("What is that dog?", "F", 6, 6), 1, 0)},                                        // what is (3)        | that dog (4)
				m_dummyKtList, m_keyTermRules, new List<Substitution>());

			Assert.AreEqual(6, pth.Phrases.Count(), "Wrong number of phrases in helper");

			pth.Filter("is", false, PhraseTranslationHelper.KeyTermFilterType.WithoutRenderings, null, false);
			Assert.AreEqual(3, pth.Phrases.Count(), "Wrong number of phrases in helper");
			pth.Sort(PhraseTranslationHelper.SortBy.Reference, true);

			Assert.AreEqual("A", pth[0].Reference);
			Assert.AreEqual("B", pth[1].Reference);
			Assert.AreEqual("E", pth[2].Reference);
		}
		public void GetPhrasesFilteredByKeyTerms_WithoutRenderings()
		{
			AddMockedKeyTerm("God", (string)null);
			AddMockedKeyTerm("Paul");
			AddMockedKeyTerm("have", (string)null);
			AddMockedKeyTerm("say");

			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] {
				new TranslatablePhrase(new TestQ("What would God have me to say with respect to Paul?", "A", 1, 1), 1, 0),       // God & have don't have renderings
				new TranslatablePhrase(new TestQ("What is Paul asking me to say with respect to that dog?", "B", 2, 2), 1, 0),
				new TranslatablePhrase(new TestQ("that dog", "C", 3, 3), 1, 0),
				new TranslatablePhrase(new TestQ("Is it okay for Paul me to talk with respect to God today?", "D", 4, 4), 1, 0), // God doesn't have a rendering
				new TranslatablePhrase(new TestQ("that dog wishes this Paul and what is say radish", "E", 5, 5), 1, 0),
				new TranslatablePhrase(new TestQ("What is that dog?", "F", 6, 6), 1, 0)},
				m_dummyKtList, m_keyTermRules, new List<Substitution>());

			Assert.AreEqual(6, pth.Phrases.Count(), "Wrong number of phrases in helper");

			pth.Filter(null, false, PhraseTranslationHelper.KeyTermFilterType.WithoutRenderings, null, false);
			pth.Sort(PhraseTranslationHelper.SortBy.Reference, true);
			Assert.AreEqual(2, pth.Phrases.Count(), "Wrong number of phrases in helper");

			Assert.AreEqual("A", pth[0].Reference);
			Assert.AreEqual("D", pth[1].Reference);
		}
		public void GetPhrasesFilteredByKeyTerms_WithRenderings_IncludeExcluded()
		{
			AddMockedKeyTerm("God", (string)null);
			AddMockedKeyTerm("Paul");
			AddMockedKeyTerm("have", (string)null);
			AddMockedKeyTerm("say");

			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] {
				new TranslatablePhrase(new TestQ("What would God have me to say with respect to Paul?", "A", 1, 1), 1, 0) { IsExcluded = true },       // God & have don't have renderings
				new TranslatablePhrase(new TestQ("What is Paul asking me to say with respect to that dog?", "B", 2, 2), 1, 0) { IsExcluded = true },
				new TranslatablePhrase(new TestQ("that dog", "C", 3, 3), 1, 0),
				new TranslatablePhrase(new TestQ("Is it okay for Paul me to talk with respect to God today?", "D", 4, 4), 1, 0), // God doesn't have a rendering
				new TranslatablePhrase(new TestQ("that dog wishes this Paul and what is say radish", "E", 5, 5), 1, 0) { IsExcluded = true },
				new TranslatablePhrase(new TestQ("What is that dog?", "F", 6, 6), 1, 0)},
				m_dummyKtList, m_keyTermRules, new List<Substitution>());

			Assert.AreEqual(6, pth.Phrases.Count(), "Wrong number of phrases in helper");

			pth.Filter(null, false, PhraseTranslationHelper.KeyTermFilterType.WithRenderings, null, false);
			pth.Sort(PhraseTranslationHelper.SortBy.Reference, true);
			Assert.AreEqual(2, pth.Phrases.Count(), "Wrong number of phrases in helper");

			Assert.AreEqual("C", pth[0].Reference);
			Assert.AreEqual("F", pth[1].Reference);

			pth.Filter(null, false, PhraseTranslationHelper.KeyTermFilterType.WithRenderings, null, true);
			Assert.AreEqual(5, pth.Phrases.Count(), "Wrong number of phrases in helper");

			Assert.AreEqual("A", pth[0].Reference); // Even though there is an unrendered term, this phrase gets included because we don't actually parse excluded phrases to look for key term matches.
			Assert.AreEqual("B", pth[1].Reference);
			Assert.AreEqual("C", pth[2].Reference);
			Assert.AreEqual("E", pth[3].Reference);
			Assert.AreEqual("F", pth[4].Reference);
		}
		public void GetPhrasesFilteredOnlyByRef_IncludeExcluded()
		{
			AddMockedKeyTerm("God", 1, 4);
			AddMockedKeyTerm("Paul", 1, 2, 5);
			AddMockedKeyTerm("have", 1, 2, 3, 4, 5, 6);
			AddMockedKeyTerm("say", 1, 2, 5);

			TranslatablePhrase tp1 = new TranslatablePhrase(new TestQ("What would God have me to say with respect to Paul?", "A", 1, 1), 1, 0);       // what would (1)     | me to (3)       | with respect to (3)
			TranslatablePhrase tp2 = new TranslatablePhrase(new TestQ("What is Paul asking me to say with respect to that dog?", "B", 2, 2), 1, 0);   // what is (3)        | asking (1)      | me to (3)           | with respect to (3) | that dog (4)
			TranslatablePhrase tp3 = new TranslatablePhrase(new TestQ("that dog", "C", 3, 3), 1, 0);                                                  // that dog (4)
			TranslatablePhrase tp4 = new TranslatablePhrase(new TestQ("Is it okay for Paul me to talk with respect to God today?", "D", 4, 4), 1, 0); // is it okay for (1) | me to (3)       | talk (1)            | with respect to (3) | today (1)
			TranslatablePhrase tp5 = new TranslatablePhrase(new TestQ("that dog wishes this Paul and what is say radish", "E", 5, 5), 1, 0);          // that dog (4)       | wishes this (1) | and (1)             | what is (3)         | radish (1)
			TranslatablePhrase tp6 = new TranslatablePhrase(new TestQ("What is that dog?", "F", 6, 6), 1, 0);                                         // what is (3)        | that dog (4)
			tp4.IsExcluded = true;
			tp5.IsExcluded = true;

			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { tp1, tp2, tp3, tp4, tp5, tp6 },
				m_dummyKtList, m_keyTermRules, new List<Substitution>());

			Assert.AreEqual(6, pth.Phrases.Count(), "Wrong number of phrases in helper");

			pth.Filter(null, false, PhraseTranslationHelper.KeyTermFilterType.All,
				((start, end, sref) => start >= 2 && end <= 5 && sref != "C"), false);
			pth.Sort(PhraseTranslationHelper.SortBy.Reference, true);
			Assert.AreEqual(1, pth.Phrases.Count(), "Wrong number of phrases in filtered list");
			Assert.AreEqual(tp2, pth[0]);

			pth.Filter(null, false, PhraseTranslationHelper.KeyTermFilterType.All,
				((start, end, sref) => start >= 2 && end <= 5 && sref != "C"), true);
			Assert.AreEqual(3, pth.Phrases.Count(), "Wrong number of phrases in filtered list");
			Assert.AreEqual(tp2, pth[0]);
			Assert.AreEqual(tp4, pth[1]);
			Assert.AreEqual(tp5, pth[2]);
		}
		public void GetPhrasesSortedByTranslation()
		{
			TranslatablePhrase tp1 = new TranslatablePhrase(new TestQ("What would God have me to say with respect to Paul?", "A", 1, 1), 1, 0);
			TranslatablePhrase tp2 = new TranslatablePhrase(new TestQ("What is Paul asking me to say with respect to that dog?", "B", 2, 2), 1, 0);
			TranslatablePhrase tp3 = new TranslatablePhrase(new TestQ("that dog", "C", 3, 3), 1, 0);
			TranslatablePhrase tp4 = new TranslatablePhrase(new TestQ("Is it okay for Paul me to talk with respect to God today?", "D", 4, 4), 1, 0);
			TranslatablePhrase tp5 = new TranslatablePhrase(new TestQ("that dog wishes this Paul and what is say radish", "E", 5, 5), 1, 0);
			TranslatablePhrase tp6 = new TranslatablePhrase(new TestQ("What is that dog?", "F", 6, 6), 1, 0);

			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { tp1, tp2, tp3, tp4, tp5, tp6 }, m_dummyKtList, m_keyTermRules, new List<Substitution>());

			tp1.Translation = "Z";
			tp2.Translation = "B";
			tp3.Translation = "alligator";
			tp4.Translation = "D";
			tp5.Translation = "e";
			tp6.Translation = "E";

			pth.Sort(PhraseTranslationHelper.SortBy.Translation, true);

			Assert.AreEqual(tp3, pth[0]);
			Assert.AreEqual(tp2, pth[1]);
			Assert.AreEqual(tp4, pth[2]);
			Assert.AreEqual(tp5, pth[3]);
			Assert.AreEqual(tp6, pth[4]);
			Assert.AreEqual(tp1, pth[5]);

			pth.Sort(PhraseTranslationHelper.SortBy.Translation, false);

			Assert.AreEqual(tp1, pth[0]);
			Assert.AreEqual(tp6, pth[1]);
			Assert.AreEqual(tp5, pth[2]);
			Assert.AreEqual(tp4, pth[3]);
			Assert.AreEqual(tp2, pth[4]);
			Assert.AreEqual(tp3, pth[5]);
		}
		public void GetPhrasesSortedByReferenceCategoryAndSequenceNum()
		{
			PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] {
				new TranslatablePhrase(new TestQ("What is the meaning of life?", "A-D", 1, 4), 0, 0),
				new TranslatablePhrase(new TestQ("Why am I here?", "A-D", 1, 4), 0, 1),
				new TranslatablePhrase(new TestQ("What would God do?", "A", 1, 1), 1, 0),
				new TranslatablePhrase(new TestQ("What is Paul asking that man?", "A", 1, 1), 1, 1),
				new TranslatablePhrase(new TestQ("When is the best time for ice cream?", "C", 3, 3), 1, 0),
				new TranslatablePhrase(new TestQ("Is it okay for Paul to talk to God today?", "D", 4, 4), 1, 0),
				new TranslatablePhrase(new TestQ("Is a dog man's best friend?", "D", 4, 4), 1, 1),
				new TranslatablePhrase(new TestQ("Why is there evil?", "E-G", 5, 6), 0, 0),
				new TranslatablePhrase(new TestQ("What is that dog?", "E", 5, 5), 1, 0),
				new TranslatablePhrase(new TestQ("What is that dog?", "E-F", 5, 6), 1, 0),
				new TranslatablePhrase(new TestQ("What is that dog?", "E-G", 5, 7), 1, 0)},
				m_dummyKtList, m_keyTermRules, new List<Substitution>());

			pth.Sort(PhraseTranslationHelper.SortBy.Reference, true);

			Assert.AreEqual("A-D", pth[0].Reference);
			Assert.AreEqual(0, pth[0].SequenceNumber);
			Assert.AreEqual("A-D", pth[1].Reference);
			Assert.AreEqual(1, pth[1].SequenceNumber);
			Assert.AreEqual("A", pth[2].Reference);
			Assert.AreEqual(0, pth[2].SequenceNumber);
			Assert.AreEqual("A", pth[3].Reference);
			Assert.AreEqual(1, pth[3].SequenceNumber);
			Assert.AreEqual("C", pth[4].Reference);
			Assert.AreEqual("D", pth[5].Reference);
			Assert.AreEqual(0, pth[5].SequenceNumber);
			Assert.AreEqual("D", pth[6].Reference);
			Assert.AreEqual(1, pth[6].SequenceNumber);
			Assert.AreEqual("E-G", pth[7].Reference);
			Assert.AreEqual(0, pth[7].Category);
			Assert.AreEqual("E", pth[8].Reference);
			Assert.AreEqual("E-F", pth[9].Reference);
			Assert.AreEqual("E-G", pth[10].Reference);
			Assert.AreEqual(1, pth[10].Category);

			pth.Sort(PhraseTranslationHelper.SortBy.Reference, false);

			Assert.AreEqual("E-G", pth[0].Reference);
			Assert.AreEqual(1, pth[0].Category);
			Assert.AreEqual("E-F", pth[1].Reference);
			Assert.AreEqual("E", pth[2].Reference);
			Assert.AreEqual("E-G", pth[3].Reference);
			Assert.AreEqual(0, pth[3].Category);
			Assert.AreEqual("D", pth[4].Reference);
			Assert.AreEqual(1, pth[4].SequenceNumber);
			Assert.AreEqual("D", pth[5].Reference);
			Assert.AreEqual(0, pth[5].SequenceNumber);
			Assert.AreEqual("C", pth[6].Reference);
			Assert.AreEqual("A", pth[7].Reference);
			Assert.AreEqual(1, pth[7].SequenceNumber);
			Assert.AreEqual("A", pth[8].Reference);
			Assert.AreEqual(0, pth[8].SequenceNumber);
			Assert.AreEqual("A-D", pth[9].Reference);
			Assert.AreEqual(1, pth[9].SequenceNumber);
			Assert.AreEqual("A-D", pth[10].Reference);
			Assert.AreEqual(0, pth[10].SequenceNumber);
		}