How to use Action method of Atata.Tests.Add class

Best Atata code snippet using Atata.Tests.Add.Action

ReferenceTextTests.cs

Source:ReferenceTextTests.cs Github

copy

Full Screen

...3061 public void GetBooksWithBlocksConnectedToReferenceText_MissingVerseInVernIsInRefBlockAlongWithStartOfFollowingVerse_VernVerseFollowingHoleAlignsToPartOfRefBlockWithVerse()3062 {3063 const string kBookId = "LUK";3064 var primaryReferenceText = ReferenceText.GetReferenceText(ReferenceTextProxy.GetOrCreate(ReferenceTextType.English));3065 Action cleanup = null;3066 try3067 {3068 var v17And18Block = GetLuke23v17And18Block(primaryReferenceText, out var lastBlockForV18, out cleanup);3069 var expectedRefTextForVerse18Part1 = "{18}\u00A0" + ((ScriptText)v17And18Block.BlockElements[3]).Content;3070 var expectedRefTextForVerse18Part2 = lastBlockForV18.GetText(true);3071 var vernacularBlocks = new List<Block>();3072 vernacularBlocks.Add(CreateNarratorBlockForVerse(14, "Pilate said, ", true, 23, kBookId));3073 AddBlockForVerseInProgress(vernacularBlocks, "Pilate", "“You say this man was inciting rebellion, but I have found no basis for your charges. ")3074 .AddVerse(15, "Herod came up empty, too, so he sent him back. How could we kill him? ")3075 .AddVerse(16, "I'll just rough him up a bit and let him go.”");3076 vernacularBlocks.Add(CreateNarratorBlockForVerse(18, "But the whole crowd is screaming like, ", true, 23, kBookId));3077 AddBlockForVerseInProgress(vernacularBlocks, "crowd", "“Eliminate this man! Give us Barabbas!” ");3078 var testProject = TestProject.CreateTestProject(TestProject.TestBook.LUK);3079 testProject.Books[0].Blocks = vernacularBlocks;3080 var result = primaryReferenceText.GetBooksWithBlocksConnectedToReferenceText(testProject, false).Single().GetScriptBlocks();3081 Assert.AreEqual(6, result.Count);3082 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3083 Assert.AreEqual(expectedRefTextForVerse18Part1, result[4].ReferenceBlocks.Single().GetText(true));3084 Assert.AreEqual(expectedRefTextForVerse18Part2, result[5].ReferenceBlocks.Single().GetText(true));3085 }3086 finally3087 {3088 cleanup?.Invoke();3089 }3090 }3091 [Test]3092 public void GetBooksWithBlocksConnectedToReferenceText_MissingVerseInVernIsInRefBlockAlongWithStartOfFollowingVerse_WholeVerseVernBlockFollowingHoleAlignsToPartOfRefBlockWithVerse()3093 {3094 const string kBookId = "LUK";3095 var vernacularBlocks = new List<Block>();3096 vernacularBlocks.Add(CreateNarratorBlockForVerse(14, "Pilate said, ", true, 23, kBookId));3097 AddBlockForVerseInProgress(vernacularBlocks, "Pilate", "“You say this man was inciting rebellion, but I have found no basis for your charges. ")3098 .AddVerse(15, "Herod came up empty, too, so he sent him back. How could we kill him? ")3099 .AddVerse(16, "I'll just rough him up a bit and let him go.”");3100 vernacularBlocks.Add(CreateNarratorBlockForVerse(18, "But the whole crowd screamed at Pilate to kill Jesus and release Barabbas.", true, 23, kBookId));3101 var testProject = TestProject.CreateTestProject(TestProject.TestBook.LUK);3102 testProject.Books[0].Blocks = vernacularBlocks;3103 var primaryReferenceText = ReferenceText.GetReferenceText(ReferenceTextProxy.GetOrCreate(ReferenceTextType.English));3104 Action cleanup = null;3105 try3106 {3107 var v17And18Block = GetLuke23v17And18Block(primaryReferenceText, out var lastBlockForV18, out cleanup);3108 var expectedRefTextForVerse18Part1 = "{18}\u00A0" + ((ScriptText)v17And18Block.BlockElements[3]).Content;3109 var expectedRefTextForVerse18Part2 = lastBlockForV18.GetText(true);3110 var result = primaryReferenceText.GetBooksWithBlocksConnectedToReferenceText(testProject, false).Single().GetScriptBlocks();3111 Assert.AreEqual(5, result.Count);3112 Assert.IsTrue(result.Take(3).All(b => b.MatchesReferenceText));3113 Assert.IsFalse(result[4].MatchesReferenceText);3114 Assert.AreEqual(2, result[4].ReferenceBlocks.Count);3115 Assert.AreEqual(expectedRefTextForVerse18Part1, result[4].ReferenceBlocks[0].GetText(true));3116 Assert.AreEqual(expectedRefTextForVerse18Part2, result[4].ReferenceBlocks[1].GetText(true));3117 }3118 finally3119 {3120 cleanup?.Invoke();3121 }3122 }3123 [Test]3124 public void ApplyTo_MissingVerseInSingleVoiceVernIsInRefBlockAlongWithStartOfFollowingVerse_WholeVerseVernBlockFollowingHoleAlignsToPartOfRefBlockWithVerse()3125 {3126 const string kBookId = "LUK";3127 var primaryReferenceText = ReferenceText.GetReferenceText(ReferenceTextProxy.GetOrCreate(ReferenceTextType.English));3128 Action cleanup = null;3129 try3130 {3131 var v17And18Block = GetLuke23v17And18Block(primaryReferenceText, out var lastBlockForV18, out cleanup);3132 var expectedRefTextForVerse18Part1 = "{18}\u00A0" + ((ScriptText)v17And18Block.BlockElements[3]).Content;3133 var expectedRefTextForVerse18Part2 = lastBlockForV18.GetText(true);3134 var vernacularBlocks = new List<Block>();3135 vernacularBlocks.Add(CreateNarratorBlockForVerse(14, "Pilate said, “You say this man was inciting rebellion, but I have found no basis for your charges. ", true, 23, kBookId)3136 .AddVerse(15, "Herod came up empty, too, so he sent him back. How could we kill him? ")3137 .AddVerse(16, "I'll just rough him up a bit and let him go.”")3138 .AddVerse(18, "But the whole crowd screamed at Pilate: “Eliminate this man! Give us Barabbas!”"));3139 var testProject = TestProject.CreateTestProject(TestProject.TestBook.LUK);3140 testProject.Books[0].Blocks = vernacularBlocks;3141 testProject.Books[0].SingleVoice = true;3142 primaryReferenceText.ApplyTo(testProject.Books[0]);3143 var result = testProject.Books[0].Blocks;3144 Assert.AreEqual(4, result.Count);3145 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3146 Assert.AreEqual(expectedRefTextForVerse18Part1 + " " + expectedRefTextForVerse18Part2, result[3].ReferenceBlocks.Single().GetText(true));3147 }3148 finally3149 {3150 cleanup?.Invoke();3151 }3152 }3153 [Test]3154 public void GetBlocksForVerseMatchedToReferenceText_BadIndex_ThrowsArgumentOutOfRangeException()3155 {3156 var vernBook = new BookScript("MAT", new List<Block>(0), m_vernVersification);3157 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, new List<Block>(0));3158 Assert.Throws<ArgumentOutOfRangeException>(() => refText.GetBlocksForVerseMatchedToReferenceText(vernBook, -1));3159 Assert.Throws<ArgumentOutOfRangeException>(() => refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0));3160 }3161 [Test]3162 public void GetBlocksForVerseMatchedToReferenceText_NoCorrespondingBookInReferenceText_ReturnsNull()3163 {3164 var vernacularBlocks = new List<Block>();3165 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Entonces dijo Jesus: ", true));3166 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3167 var refText = TestReferenceText.CreateTestReferenceText("LUK", new List<Block>(0));3168 Assert.IsNull(refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0));3169 }3170 [TestCase(0)]3171 [TestCase(1)]3172 [TestCase(2)]3173 [TestCase(3)]3174 public void GetBlocksForVerseMatchedToReferenceText_VernBlocksAreForSingleVerse_ReturnedBlocksAreMatchedClonesOfOriginals(int iBlock)3175 {3176 var vernacularBlocks = new List<Block>();3177 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Entonces dijo Jesus: ", true));3178 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "Este es versiculo uno, ");3179 AddNarratorBlockForVerseInProgress(vernacularBlocks, "asi dijo. Pero Paul replico: ");3180 AddBlockForVerseInProgress(vernacularBlocks, "Paul", "Asi pense, ");3181 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3182 var referenceBlocks = new List<Block>();3183 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Then Jesus said, ", true));3184 AddBlockForVerseInProgress(referenceBlocks, "Jesus", "“This is verse one.” ");3185 AddNarratorBlockForVerseInProgress(referenceBlocks, "But Paul replied, ");3186 AddBlockForVerseInProgress(referenceBlocks, "Paul", "“That's what I thought.”");3187 referenceBlocks.Add(CreateNarratorBlockForVerse(2, "Extra stuff that is not used. ", true).AddVerse(3));3188 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3189 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3190 Assert.AreEqual(vernacularBlocks[iBlock].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3191 var result = matchup.CorrelatedBlocks;3192 Assert.IsTrue(result.Select(b => b.ToString()).SequenceEqual(vernacularBlocks.Select(b => b.ToString())));3193 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3194 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3195 }3196 [TestCase(0)]3197 [TestCase(1)]3198 [TestCase(2)]3199 [TestCase(3)]3200 public void GetBlocksForVerseMatchedToReferenceText_VernAndRefHaveMultipleSingleBlockVerses_ReturnsSingleClonedAndMatchedBlock(int iBlock)3201 {3202 var vernacularBlocks = new List<Block>();3203 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Entonces dijo Jesus: ", true));3204 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 2, "Nunca os dejare! ", true));3205 vernacularBlocks.Add(CreateNarratorBlockForVerse(3, "Entonces fue con sus discipulos al jardin, donde Pedro dijo: ", true));3206 vernacularBlocks.Add(CreateBlockForVerse("Peter", 4, "Me gusta este lugar.", true));3207 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3208 var referenceBlocks = new List<Block>();3209 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Then Jesus said, ", true));3210 referenceBlocks.Add(CreateBlockForVerse("Jesus", 2, "“I will never leave you!” ", true));3211 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "Then he went with his disciples to the garden, whereupon Peter said: ", true));3212 referenceBlocks.Add(CreateBlockForVerse("Peter", 4, "“I like this place.”", true));3213 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3214 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3215 Assert.AreEqual(vernacularBlocks[iBlock].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3216 var result = matchup.CorrelatedBlocks;3217 Assert.AreEqual(vernacularBlocks[iBlock].ToString(), result.Single().ToString());3218 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3219 Assert.IsTrue(result.Single().MatchesReferenceText);3220 Assert.AreEqual(referenceBlocks[iBlock].GetText(true), result.Single().GetPrimaryReferenceText());3221 }3222 [TestCase(1)]3223 [TestCase(2)]3224 [TestCase(3)]3225 [TestCase(4)]3226 public void GetBlocksForVerseMatchedToReferenceText_VerseHasMultipleBlocks_ReturnsMultipleClonedAndMatchedBlocks(int iBlock)3227 {3228 var vernacularBlocks = new List<Block>();3229 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Entonces dijo Jesus: ", true));3230 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 2, "Nunca os dejare! ", true));3231 AddNarratorBlockForVerseInProgress(vernacularBlocks, "En ese momento, Pedro entro exclamando: ");3232 AddBlockForVerseInProgress(vernacularBlocks, "Peter", "Nos quieren hundir con los impuestos exagerados! ");3233 AddNarratorBlockForVerseInProgress(vernacularBlocks, "Claro que estaba exagerando.");3234 vernacularBlocks.Add(CreateNarratorBlockForVerse(3, "Eso es todo.", true));3235 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3236 var referenceBlocks = new List<Block>();3237 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Then Jesus said, ", true));3238 referenceBlocks.Add(CreateBlockForVerse("Jesus", 2, "“I will never leave you!” ", true));3239 AddNarratorBlockForVerseInProgress(referenceBlocks, "But just then, Peter burst in and exclaimed: ");3240 AddBlockForVerseInProgress(referenceBlocks, "Peter", "They want to tax us to death! ");3241 AddNarratorBlockForVerseInProgress(referenceBlocks, "Of course, he was exagerating.");3242 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "That's all.", true));3243 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3244 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3245 Assert.AreEqual(vernacularBlocks[iBlock].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3246 var result = matchup.CorrelatedBlocks;3247 Assert.IsTrue(result.Select(b => b.ToString()).SequenceEqual(vernacularBlocks.Skip(1).Take(4).Select(b => b.ToString())));3248 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3249 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3250 Assert.IsTrue(referenceBlocks.Skip(1).Take(4).Select(r => r.GetText(true)).SequenceEqual(result.Select(v => v.GetPrimaryReferenceText())));3251 }3252 /// <summary>3253 /// PG-1311: Block has multiple verses. Last verse bleeds into subsequent block, but a verse is missing so the first verse number3254 /// present in the subsequent block is > the initial verse number + 1.3255 /// </summary>3256 [Test]3257 public void GetBlocksForVerseMatchedToReferenceText_MultipleVersesInVernBlockNextBlockStartsWith_ReturnsMatchupCoveringInitialBlockOnly()3258 {3259 var vernacularBlocks = new List<Block>();3260 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 31, "«Dœ olonœ asœmœ, uzu á nœ ye sœ ɓa sœnda, tshe ye ga mangba ye nene. ", false, 17)3261 .AddVerse(32, "'E gbetshelœ 'e tœ upu nœ awo Lota kane. ")3262 .AddVerse(33, "Uzu neke á tshe para awa ndœ kœgbɔndœ soro tshu; kashe tsheneke nœ nene dá she. ")3263 .AddVerse(34, "Mœ sœ 'e, lœ butshɔnœ asœmœ, ayakoshe: endje za anga bale, yé anga œ sœpe. ")3264 .AddVerse(35, "Ayashe bisha œ sœ kœtɔ œrœ tœ œsœnœ bale: endje za anga bale, yé anga œ sœpe. "));3265 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kUnexpectedCharacter, 37, "[ ", false, 17)3266 .AddVerse(37, "Ayambarœ nœ Yisu yu she adœke:"));3267 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kUnexpectedCharacter, " «Œrœnœ atamœ œ mbœrœtœ endje kpœta Gbozu?» ", "p");3268 AddNarratorBlockForVerseInProgress(vernacularBlocks, "é tshe kœgi fœ endje adœke: ", "LUK");3269 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Osho á oko sœ tœnœ, œ kœngbɔtœ endje ɓa zœ.»", "p");3270 var vernBook = new BookScript("LUK", vernacularBlocks, m_vernVersification);3271 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3272 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);3273 Assert.AreEqual(1, matchup.OriginalBlockCount);3274 }3275 [TestCase(1)]3276 [TestCase(2)]3277 [TestCase(3)]3278 [TestCase(4)]3279 public void GetBlocksForVerseMatchedToReferenceText_VerseHasMultipleBlocksWithCharactersAssignedThatDoNotMatchReference_ReturnsMultipleClonedAndMismatchedBlocks(int iBlock)3280 {3281 var vernacularBlocks = new List<Block>();3282 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Esto es lo que paso.", true));3283 vernacularBlocks.Add(CreateNarratorBlockForVerse(2, "Entonces dijo Jesus:", true));3284 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "—Nunca os dejare!");3285 AddBlockForVerseInProgress(vernacularBlocks, "Peter", "—Gracias.");3286 AddNarratorBlockForVerseInProgress(vernacularBlocks, "respondio Pedro.");3287 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3288 var referenceBlocks = new List<Block>();3289 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Then Jesus said, ", true));3290 referenceBlocks.Add(CreateBlockForVerse("Jesus", 2, "“I will never leave you!” ", true));3291 AddNarratorBlockForVerseInProgress(referenceBlocks, "But just then, John burst in and exclaimed: ");3292 AddBlockForVerseInProgress(referenceBlocks, "John", "They want to tax us to death! ");3293 AddNarratorBlockForVerseInProgress(referenceBlocks, "Of course, he was exagerating.");3294 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "That's all.", true));3295 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3296 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3297 Assert.AreEqual(vernacularBlocks[iBlock].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3298 var result = matchup.CorrelatedBlocks;3299 Assert.IsTrue(result.Select(b => b.ToString()).SequenceEqual(vernacularBlocks.Skip(1).Take(4).Select(b => b.ToString())));3300 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3301 Assert.IsFalse(result.Take(3).All(b => b.MatchesReferenceText));3302 Assert.IsTrue(referenceBlocks.Skip(1).Take(3).Select(r => r.GetText(true)).SequenceEqual(result[0].ReferenceBlocks.Select(b => b.GetText(true))));3303 Assert.IsTrue(result[3].MatchesReferenceText);3304 }3305 [TestCase(1)]3306 [TestCase(2)]3307 [TestCase(3)]3308 [TestCase(4)]3309 public void GetBlocksForVerseMatchedToReferenceText_VerseHasMultipleBlocksWithoutCharactersAssignedThatCouldMatchReference_ReturnsMultipleClonedAndMatchedBlocks(int iBlock)3310 {3311 var vernacularBlocks = new List<Block>();3312 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Entonces dijo Jesus: ", true));3313 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kAmbiguousCharacter, 2, "Nunca os dejare! ", true));3314 AddNarratorBlockForVerseInProgress(vernacularBlocks, "En ese momento, Pedro entro exclamando: ");3315 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "Nos quieren hundir con los impuestos exagerados! ");3316 AddNarratorBlockForVerseInProgress(vernacularBlocks, "Claro que estaba exagerando.");3317 vernacularBlocks.Add(CreateNarratorBlockForVerse(3, "Eso es todo.", true));3318 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3319 var referenceBlocks = new List<Block>();3320 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Then Jesus said, ", true));3321 referenceBlocks.Add(CreateBlockForVerse("Jesus", 2, "“I will never leave you!” ", true));3322 AddNarratorBlockForVerseInProgress(referenceBlocks, "But just then, Peter burst in and exclaimed: ");3323 AddBlockForVerseInProgress(referenceBlocks, "Peter", "They want to tax us to death! ");3324 AddNarratorBlockForVerseInProgress(referenceBlocks, "Of course, he was exagerating.");3325 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "That's all.", true));3326 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3327 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3328 Assert.AreEqual(vernacularBlocks[iBlock].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3329 var result = matchup.CorrelatedBlocks;3330 Assert.IsTrue(result.Select(b => b.ToString()).SequenceEqual(vernacularBlocks.Skip(1).Take(4).Select(b => b.ToString())));3331 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3332 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3333 Assert.IsTrue(referenceBlocks.Skip(1).Take(4).Select(r => r.GetText(true)).SequenceEqual(result.Select(v => v.GetPrimaryReferenceText())));3334 }3335 [TestCase(0)]3336 [TestCase(1)]3337 public void GetBlocksForVerseMatchedToReferenceText_VernVerseStartsMidBlock_ReturnedBlocksAreMatchedClonesOfOriginals(int iBlock)3338 {3339 var vernacularBlocks = new List<Block>();3340 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Partieron de alli para Jerico. ", true).AddVerse(2, "Entonces dijo Jesus: "));3341 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "Come to me you who are weary.");3342 vernacularBlocks.Add(CreateNarratorBlockForVerse(3, "Another verse."));3343 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3344 var referenceBlocks = new List<Block>();3345 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "They journeyed on from there to Jericho.", true));3346 referenceBlocks.Add(CreateNarratorBlockForVerse(2, "Then Jesus said,"));3347 AddBlockForVerseInProgress(referenceBlocks, "Jesus", "Come to me you who are weary.");3348 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "Extra stuff that is not used. ", true));3349 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3350 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3351 Assert.AreEqual(vernacularBlocks[iBlock].BlockElements.OfType<ScriptText>().First().Content,3352 matchup.CorrelatedAnchorBlock.BlockElements.OfType<ScriptText>().First().Content);3353 var result = matchup.CorrelatedBlocks;3354 Assert.AreEqual(3, result.Count);3355 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3356 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3357 Assert.AreEqual("{1}\u00A0Partieron de alli para Jerico. ", result[0].GetText(true));3358 Assert.AreEqual("{2}\u00A0Entonces dijo Jesus: ", result[1].GetText(true));3359 Assert.AreEqual("Come to me you who are weary.", result[2].GetText(true));3360 Assert.IsTrue(result.Select(b => b.GetPrimaryReferenceText()).SequenceEqual(referenceBlocks.Take(3).Select(b => b.GetText(true))));3361 }3362 [Test]3363 public void GetBlocksForVerseMatchedToReferenceText_EnglishRefVerseStartsMidBlock_MatchupIncludesPrecedingVerse()3364 {3365 var vernacularBlocks = new List<Block>();3366 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Maria i karim Jisas long taun Betlehem long distrik Judia long taim Herot i stap king. Em i karim Jisas pinis, na bihain sampela saveman bilong hap sankamap i kam long Jerusalem na ol i askim nabaut olsem, ", true, 2));3367 vernacularBlocks.Add(CreateBlockForVerse("magi", 2, "\"Nupela pikinini em king bilong ol Juda, em i stap we ? Mipela i lukim sta bilong en long hap sankamap, na mipela i kam bilong lotu long em.\"", false, 2));3368 vernacularBlocks.Add(CreateNarratorBlockForVerse(3, "King Herot i... ", true, 2));3369 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3370 var referenceBlocks = new List<Block>();3371 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Now when Jesus was born in Bethlehem of Judea in the days of King Herod, behold, wise men from the east came to Jerusalem,", true, 2).AddVerse(2, "saying, "));3372 AddBlockForVerseInProgress(referenceBlocks, "magi", " “Where is the one who is born King of the Jews? For we saw his star in the east, and have come to worship him.”");3373 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "When King Herod... ", true, 2));3374 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3375 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3376 Assert.AreEqual(vernacularBlocks[1].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3377 var result = matchup.CorrelatedBlocks;3378 Assert.AreEqual(2, result.Count);3379 Assert.AreEqual(0, vernacularBlocks.Intersect(result).Count());3380 Assert.IsFalse(result[0].MatchesReferenceText);3381 Assert.IsTrue(result[1].MatchesReferenceText);3382 Assert.AreEqual("{1}\u00A0Maria i karim Jisas long taun Betlehem long distrik Judia long taim Herot i stap king. Em i karim Jisas pinis, na bihain sampela saveman bilong hap sankamap i kam long Jerusalem na ol i askim nabaut olsem, ", result[0].GetText(true));3383 Assert.AreEqual("{2}\u00A0\"Nupela pikinini em king bilong ol Juda, em i stap we ? Mipela i lukim sta bilong en long hap sankamap, na mipela i kam bilong lotu long em.\"", result[1].GetText(true));3384 Assert.IsTrue(result.Select(b => b.ReferenceBlocks.Single().GetText(true)).SequenceEqual(referenceBlocks.Take(2).Select(b => b.GetText(true))));3385 Assert.AreEqual(referenceBlocks[1].GetText(true), result[1].GetPrimaryReferenceText());3386 }3387 [TestCase(0)]3388 [TestCase(1)]3389 [TestCase(2)]3390 [TestCase(3)]3391 [TestCase(4)]3392 public void GetBlocksForVerseMatchedToReferenceText_Prematched_SavedMatchesAreNotOverwritten(int iBlock)3393 {3394 var vernacularBlocks = new List<Block>();3395 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Esto es lo que paso.", true));3396 vernacularBlocks.Add(CreateNarratorBlockForVerse(2, "Entonces dijo Jesus:", true));3397 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "—Nunca os dejare!");3398 AddBlockForVerseInProgress(vernacularBlocks, "Peter", "—Gracias.");3399 AddNarratorBlockForVerseInProgress(vernacularBlocks, "respondio Pedro.");3400 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3401 var referenceBlocks = new List<Block>();3402 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Then Jesus said, ", true));3403 referenceBlocks.Add(CreateBlockForVerse("Jesus", 2, "“I will never leave you!” ", true));3404 AddNarratorBlockForVerseInProgress(referenceBlocks, "But just then, John burst in and exclaimed: ");3405 AddBlockForVerseInProgress(referenceBlocks, "John", "They want to tax us to death! ");3406 AddNarratorBlockForVerseInProgress(referenceBlocks, "Of course, he was exagerating.");3407 referenceBlocks.Add(CreateNarratorBlockForVerse(3, "That's all.", true));3408 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3409 // Now pre-match them:3410 vernacularBlocks[0].SetMatchedReferenceBlock(CreateNarratorBlockForVerse(1, "This is what happened.", true));3411 vernacularBlocks[1].SetMatchedReferenceBlock(CreateNarratorBlockForVerse(2, "Then Jesus said:", true));3412 vernacularBlocks[2].SetMatchedReferenceBlock(referenceBlocks[1].Clone());3413 vernacularBlocks[2].ReferenceBlocks.Single().BlockElements.RemoveAt(0); // Get rid of verse number3414 vernacularBlocks[3].SetMatchedReferenceBlock(new Block("p", 1, 2)3415 {3416 CharacterId = "Peter",3417 BlockElements = new List<BlockElement> { new ScriptText("“Thanks,”") }3418 });3419 vernacularBlocks[4].SetMatchedReferenceBlock(new Block("p", 1, 2)3420 {3421 CharacterId = vernBook.NarratorCharacterId,3422 BlockElements = new List<BlockElement> { new ScriptText("answered Peter.") }3423 });3424 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, iBlock);3425 Assert.AreEqual(vernacularBlocks[iBlock].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3426 Assert.IsFalse(matchup.HasOutstandingChangesToApply);3427 }3428 [Test]3429 public void GetBlocksForVerseMatchedToReferenceText_EndOfBookWhereReferenceTextCombinesTwoVerses_MatchesToRelevantPartOfRefBlock()3430 {3431 // The last block of the standard reference text for Hebrews combines verse 24 and 25.3432 const string kBookId = "HEB";3433 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3434 var v25RefTextBlock = refText.Books.Single(b => b.BookId == kBookId).GetBlocksForVerse(13, 25).Single();3435 Assert.AreEqual(24, v25RefTextBlock.InitialStartVerseNumber, "Test setup conditions not met");3436 Assert.AreEqual("25", ((Verse)v25RefTextBlock.BlockElements[2]).Number, "Test setup conditions not met");3437 var expectedRefTextForVerse25 = "{25}\u00A0" + ((ScriptText)v25RefTextBlock.BlockElements[3]).Content;3438 var vernacularBlocks = new List<Block> { CreateNarratorBlockForVerse(25, "Grace be unto you all.", true, 13, kBookId) };3439 var vernBook = new BookScript(kBookId, vernacularBlocks, m_vernVersification);3440 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);3441 Assert.AreEqual(vernacularBlocks[0].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3442 Assert.AreEqual(1, matchup.CorrelatedBlocks.Count);3443 Assert.IsTrue(matchup.CorrelatedBlocks[0].MatchesReferenceText);3444 Assert.AreEqual(expectedRefTextForVerse25, matchup.CorrelatedBlocks[0].GetPrimaryReferenceText());3445 }3446 [Test]3447 public void GetBlocksForVerseMatchedToReferenceText_AllowSplitting_VernBlockIsFirstVerseOfCombinedReferenceTextBlock_MatchupIncludesBothVerses()3448 {3449 var vernacularBlocks = new List<Block> {3450 CreateNarratorBlockForVerse(24, "Köszöntsétek minden elõljárótokat és a szenteket mind. Köszöntenek titeket az Olaszországból valók. ", true, 13, "HEB"),3451 CreateNarratorBlockForVerse(25, "Kegyelem mindnyájatokkal! Ámen!", true, 13, "HEB")3452 };3453 var vernBook = new BookScript("HEB", vernacularBlocks, m_vernVersification);3454 // The last block of the standard reference text for Hebrews combines verse 24 and 25.3455 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3456 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0); // allowing splitting is the default3457 Assert.AreEqual(vernacularBlocks[0].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3458 Assert.AreEqual(2, matchup.CorrelatedBlocks.Count);3459 Assert.IsFalse(matchup.CorrelatedBlocks[0].MatchesReferenceText);3460 Assert.AreEqual(24, matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().InitialStartVerseNumber);3461 Assert.AreEqual(24, matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().LastVerseNum);3462 Assert.IsTrue(matchup.CorrelatedBlocks[1].MatchesReferenceText);3463 Assert.AreEqual(25, matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().InitialStartVerseNumber);3464 Assert.AreEqual(25, matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().LastVerseNum);3465 }3466 [Test]3467 public void GetBlocksForVerseMatchedToReferenceText_DisallowSplitting_VernBlockIsFirstVerseOfCombinedReferenceTextBlock_MatchupIncludesBothVerses()3468 {3469 var vernacularBlocks = new List<Block> {3470 CreateNarratorBlockForVerse(24, "Köszöntsétek minden elõljárótokat és a szenteket mind. Köszöntenek titeket az Olaszországból valók. ", true, 13, "HEB"),3471 CreateNarratorBlockForVerse(25, "Kegyelem mindnyájatokkal! Ámen!", true, 13, "HEB")3472 };3473 var vernBook = new BookScript("HEB", vernacularBlocks, m_vernVersification);3474 // The last block of the standard reference text for Hebrews combines verse 24 and 25.3475 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3476 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, allowSplitting: false);3477 Assert.AreEqual(vernacularBlocks[0].GetText(true), matchup.CorrelatedAnchorBlock.GetText(true));3478 Assert.AreEqual(2, matchup.CorrelatedBlocks.Count);3479 Assert.IsFalse(matchup.CorrelatedBlocks[0].MatchesReferenceText);3480 Assert.AreEqual(1, matchup.CorrelatedBlocks[0].ReferenceBlocks.Count);3481 Assert.IsFalse(matchup.CorrelatedBlocks[1].MatchesReferenceText);3482 Assert.AreEqual(1, matchup.CorrelatedBlocks[1].ReferenceBlocks.Count);3483 Assert.AreEqual(matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().GetText(true), matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().GetText(true),3484 "Since we're not allowing the reference block to be split, we should match the block with v. 24 and v. 25 to both vern blocks.");3485 }3486 [Test]3487 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasExtraChapterBeyondLastChapterOfRefText_VernVersesInExtraChapterRemainsUnmatched()3488 {3489 var vernacularBlocks = new List<Block> {3490 CreateNarratorBlockForVerse(24, "Köszöntsétek minden elõljárótokat és a szenteket mind. Köszöntenek titeket az Olaszországból valók. ", true, 13, "HEB")3491 .AddVerse(25, "Kegyelem mindnyájatokkal! Ámen!"),3492 NewChapterBlock("HEB", 14),3493 CreateNarratorBlockForVerse(1, "Alright, who's the wise guy?", true, 14, "HEB"),3494 CreateNarratorBlockForVerse(2, "This is not supposed to be here", true, 14, "HEB")3495 };3496 var vernBook = new BookScript("HEB", vernacularBlocks, m_vernVersification);3497 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3498 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 2);3499 Assert.IsFalse(matchup.CorrelatedBlocks.Last().MatchesReferenceText);3500 matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 3);3501 Assert.IsFalse(matchup.CorrelatedBlocks.Last().MatchesReferenceText);3502 }3503 [Test]3504 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasLeadingSquareBracket_BlockIsNotSplitBetweenBracketAndVerseNumber()3505 {3506 var vernacularBlocks = new List<Block> {3507 CreateNarratorBlockForVerse(8, "Ci mon gukatti woko ki i lyel, gucako ŋwec ki myelkom pi lworo ma omakogi matek twatwal; lworo ogeŋogi tito lokke ki ŋatti mo. ", true, 16, "MRK"),3508 CreateNarratorBlockForVerse(9, "Ka en doŋ ocer odiko con i nino mukwoŋo me cabit, okwoŋo nyutte bot Maliam Lamagdala, ma yam en oryemo cen abiro i kome-ni. ", true, 16, "MRK")3509 .AddVerse(10, "En otugi tero lok bot jo ma yam gibedo kwede, i kare ma gitye ki cola ki kumu-gu. ").AddVerse(11, "Ka guwinyo ni en tye gire makwo, dok ni otyeko nyutte, kome onen bot Maliam, pe guye lokke. "),3510 };3511 vernacularBlocks.Last().BlockElements.Insert(0, new ScriptText("["));3512 var vernBook = new BookScript("MRK", vernacularBlocks, m_vernVersification);3513 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3514 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3515 Assert.AreEqual(3, matchup.CorrelatedBlocks.Count);3516 var firstCorrelatedBlock = matchup.CorrelatedBlocks.First();3517 Assert.AreEqual(3, firstCorrelatedBlock.BlockElements.Count);3518 Assert.AreEqual("[", ((ScriptText)firstCorrelatedBlock.BlockElements[0]).Content);3519 Assert.AreEqual("9", ((Verse)firstCorrelatedBlock.BlockElements[1]).Number);3520 Assert.IsTrue(((ScriptText)firstCorrelatedBlock.BlockElements[2]).Content.StartsWith("Ka en doŋ"));3521 }3522 #region PG-794 (misalignment between vern and ref)3523 /// <summary>3524 /// This is the text for the specific scenario detailed in PG-794.3525 /// </summary>3526 [Test]3527 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasPreAnnouncedQuoteAsSingleBlockThatIsSplitInRefText_AllTextFromRefTextIsIncluded()3528 {3529 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3530 var refTextRev = refText.GetBook("REV");3531 var refBlockRev14V12 = refTextRev.GetBlocksForVerse(14, 12).Single();3532 var refBlocksRev14V13 = refTextRev.GetBlocksForVerse(14, 13).ToList();3533 VerifyCharacterVerseEntriesForRev4V12To13(refBlockRev14V12, refBlocksRev14V13);3534 var vernacularBlocks = new List<Block>3535 {3536 new Block("c", 14)3537 {3538 BookCode = refTextRev.BookId,3539 CharacterId = CharacterVerseData.GetStandardCharacterId(refTextRev.BookId, CharacterVerseData.StandardCharacter.BookOrChapter),3540 },3541 CreateNarratorBlockForVerse(12, "'Ŋwacɩa ya ŋeni, ɩya Laagɔ 'la ncɛlɩa ‑ɔ 'plɩlɩ 'lɛ ɔla ‑jlɩmaa 'kʋ 'nyɩ ‑ɔ ‑ka 'lɛ Zozii 'la pɔɔtɛtɛ na, 'kanɩ pɔlɛ kla. ", true, 14, refTextRev.BookId)3542 .AddVerse(13, "'Nyɩ n ‑ya ‑blɩɩzɔn bhlo 'nu, ʋ 'wlʋlʋa ‑laagɔɔn 'nyɩ ʋ claa lebhe: ")3543 };3544 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Zie lebhe: Ma ‑kʋnɩ ‑pɔtɔnʋ 'nanɩ, maa ‑ɔ 'kulu 'lɛ ‑Kwlenyɔ nɩkplaan na!» "); // Write: Blessed...3545 AddNarratorBlockForVerseInProgress(vernacularBlocks, "‑Ghɛɛ, 'Wugoa nabhe: ", refTextRev.BookId); // The Holy Spirit said:3546 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«'Naa ma 'lɩnɩ lobholia ‑tɛtɛa ma nʋ 'lɛ na 'la nyɔkwɛa, sa mala nʋnʋgbɩa gɩlɩ maa na.»"); // Yes, that they...3547 var vernBook = new BookScript(refTextRev.BookId, vernacularBlocks, m_vernVersification);3548 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3549 Assert.AreEqual(5, matchup.CorrelatedBlocks.Count);3550 Assert.AreEqual(refBlockRev14V12.GetText(true), matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().GetText(true));3551 Assert.AreEqual(refBlocksRev14V13[0].GetText(true), matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().GetText(true),3552 $"Vern: {matchup.CorrelatedBlocks[1].GetText(true)}");3553 Assert.AreEqual(refBlocksRev14V13[1].GetText(true), matchup.CorrelatedBlocks[2].ReferenceBlocks.Single().GetText(true),3554 $"Vern: {matchup.CorrelatedBlocks[2].GetText(true)}");3555 Assert.AreEqual(refBlocksRev14V13[3].GetText(true), matchup.CorrelatedBlocks[3].ReferenceBlocks.Single().GetText(true),3556 $"Vern: {matchup.CorrelatedBlocks[3].GetText(true)}");3557 Assert.AreEqual(refBlocksRev14V13[2].GetText(true) + refBlocksRev14V13[4].GetText(true),3558 String.Join("", matchup.CorrelatedBlocks[4].ReferenceBlocks.Select(r => r.GetText(true))),3559 $"Vern: {matchup.CorrelatedBlocks[4].GetText(true)}");3560 }3561 /// <summary>3562 /// This scenario has the two lines by the Holy Spirit combined, but with the "he said" at the end.3563 /// </summary>3564 [Test]3565 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasPostAnnouncedQuoteAsSingleBlockThatIsSplitInRefText_AllTextFromRefTextMatchesBlockForCorrectSpeaker()3566 {3567 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3568 var refTextRev = refText.GetBook("REV");3569 var refBlockRev14V12 = refTextRev.GetBlocksForVerse(14, 12).Single();3570 var refBlocksRev14V13 = refTextRev.GetBlocksForVerse(14, 13).ToList();3571 VerifyCharacterVerseEntriesForRev4V12To13(refBlockRev14V12, refBlocksRev14V13);3572 var vernacularBlocks = new List<Block>3573 {3574 new Block("c", 14)3575 {3576 BookCode = refTextRev.BookId,3577 CharacterId = CharacterVerseData.GetStandardCharacterId(refTextRev.BookId, CharacterVerseData.StandardCharacter.BookOrChapter),3578 },3579 CreateNarratorBlockForVerse(12, "'Ŋwacɩa ya ŋeni, ɩya Laagɔ 'la ncɛlɩa ‑ɔ 'plɩlɩ 'lɛ ɔla ‑jlɩmaa 'kʋ 'nyɩ ‑ɔ ‑ka 'lɛ Zozii 'la pɔɔtɛtɛ na, 'kanɩ pɔlɛ kla. ", true, 14, refTextRev.BookId)3580 .AddVerse(13, "Then I heard a heavenly voice articulating: ")3581 };3582 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Escriba: Blessed are the muertos from here on out!» ");3583 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Yes, that they can get some sleep; their labores les siguen.»");3584 AddNarratorBlockForVerseInProgress(vernacularBlocks, "said the Holy Spirit.", refTextRev.BookId);3585 var vernBook = new BookScript(refTextRev.BookId, vernacularBlocks, m_vernVersification);3586 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3587 Assert.AreEqual(5, matchup.CorrelatedBlocks.Count);3588 Assert.AreEqual(refBlockRev14V12.GetText(true), matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().GetText(true));3589 Assert.AreEqual(refBlocksRev14V13[0].GetText(true), matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().GetText(true),3590 $"Vern: {matchup.CorrelatedBlocks[1].GetText(true)}");3591 Assert.AreEqual(refBlocksRev14V13[1].GetText(true), matchup.CorrelatedBlocks[2].ReferenceBlocks.Single().GetText(true),3592 $"Vern: {matchup.CorrelatedBlocks[2].GetText(true)}");3593 Assert.AreEqual(refBlocksRev14V13[2].GetText(true) + refBlocksRev14V13[4].GetText(true),3594 String.Join("", matchup.CorrelatedBlocks[3].ReferenceBlocks.Select(r => r.GetText(true))),3595 $"Vern: {matchup.CorrelatedBlocks[3].GetText(true)}");3596 Assert.AreEqual(refBlocksRev14V13[3].GetText(true), matchup.CorrelatedBlocks[4].ReferenceBlocks.Single().GetText(true),3597 $"Vern: {matchup.CorrelatedBlocks[4].GetText(true)}");3598 }3599 /// <summary>3600 /// This scenario has the two lines by the Holy Spirit combined, but with both a preceeding announcement and a closing "he said".3601 /// We could possibly hope for better results, but it's pretty tricky to figure out what's best in this case and probably harder3602 /// to write intelligible code to do it. So we'll be content if everything in the reference text is just preserved in the corretc order.3603 /// </summary>3604 [Test]3605 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasPreAndPostAnnouncedQuoteAsSingleBlockThatIsSplitInRefText_AllTextFromRefTextIncluded()3606 {3607 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3608 var refTextRev = refText.GetBook("REV");3609 var refBlockRev14V12 = refTextRev.GetBlocksForVerse(14, 12).Single();3610 var refBlocksRev14V13 = refTextRev.GetBlocksForVerse(14, 13).ToList();3611 VerifyCharacterVerseEntriesForRev4V12To13(refBlockRev14V12, refBlocksRev14V13);3612 var vernacularBlocks = new List<Block>3613 {3614 new Block("c", 14)3615 {3616 BookCode = refTextRev.BookId,3617 CharacterId = CharacterVerseData.GetStandardCharacterId(refTextRev.BookId, CharacterVerseData.StandardCharacter.BookOrChapter),3618 },3619 CreateNarratorBlockForVerse(12, "'Ŋwacɩa ya ŋeni, ɩya Laagɔ 'la ncɛlɩa ‑ɔ 'plɩlɩ 'lɛ ɔla ‑jlɩmaa 'kʋ 'nyɩ ‑ɔ ‑ka 'lɛ Zozii 'la pɔɔtɛtɛ na, 'kanɩ pɔlɛ kla. ", true, 14, refTextRev.BookId)3620 .AddVerse(13, "Then I heard a heavenly voice articulating: ")3621 };3622 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Escriba: Blessed are the muertos from here on out!» ");3623 AddNarratorBlockForVerseInProgress(vernacularBlocks, "The Holy Spirit responded: ", refTextRev.BookId);3624 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Yes, that they can get some sleep; their labores les siguen,» ");3625 AddNarratorBlockForVerseInProgress(vernacularBlocks, "end quote.", refTextRev.BookId);3626 var vernBook = new BookScript(refTextRev.BookId, vernacularBlocks, m_vernVersification);3627 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3628 Assert.AreEqual(6, matchup.CorrelatedBlocks.Count);3629 Assert.AreEqual(refBlockRev14V12.GetText(true), matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().GetText(true));3630 Assert.IsTrue(refBlocksRev14V13.Select(r => r.GetText(true)).SequenceEqual(matchup.CorrelatedBlocks.Skip(1).SelectMany(c =>3631 c.ReferenceBlocks).Select(rb => rb.GetText(true))));3632 }3633 /// <summary>3634 /// This scenario has the two lines by the Holy Spirit split as in the reference text, with an extra closing "he said".3635 /// </summary>3636 [Test]3637 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasPostAnnouncedQuote_AllTextFromRefTextMatchesWithExtraVernLineUnmatched()3638 {3639 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3640 var refTextRev = refText.GetBook("REV");3641 var refBlockRev14V12 = refTextRev.GetBlocksForVerse(14, 12).Single();3642 var refBlocksRev14V13 = refTextRev.GetBlocksForVerse(14, 13).ToList();3643 VerifyCharacterVerseEntriesForRev4V12To13(refBlockRev14V12, refBlocksRev14V13);3644 var vernacularBlocks = new List<Block>3645 {3646 new Block("c", 14)3647 {3648 BookCode = refTextRev.BookId,3649 CharacterId = CharacterVerseData.GetStandardCharacterId(refTextRev.BookId, CharacterVerseData.StandardCharacter.BookOrChapter),3650 },3651 CreateNarratorBlockForVerse(12, "'Ŋwacɩa ya ŋeni, ɩya Laagɔ 'la ncɛlɩa ‑ɔ 'plɩlɩ 'lɛ ɔla ‑jlɩmaa 'kʋ 'nyɩ ‑ɔ ‑ka 'lɛ Zozii 'la pɔɔtɛtɛ na, 'kanɩ pɔlɛ kla. ", true, 14, refTextRev.BookId)3652 .AddVerse(13, "Then I heard a heavenly voice articulating: ")3653 };3654 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Escriba: Blessed are the muertos from here on out!» ");3655 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Yes,» ");3656 AddNarratorBlockForVerseInProgress(vernacularBlocks, "the Holy Spirit responded, ", refTextRev.BookId);3657 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«that they can get some sleep; their labores les siguen,» ");3658 AddNarratorBlockForVerseInProgress(vernacularBlocks, "end quote.", refTextRev.BookId);3659 var vernBook = new BookScript(refTextRev.BookId, vernacularBlocks, m_vernVersification);3660 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3661 Assert.AreEqual(7, matchup.CorrelatedBlocks.Count);3662 Assert.AreEqual(refBlockRev14V12.GetText(true), matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().GetText(true));3663 for (int i = 1; i < matchup.CorrelatedBlocks.Count - 1; i++)3664 {3665 Assert.AreEqual(refBlocksRev14V13[i - 1].GetText(true), matchup.CorrelatedBlocks[i].ReferenceBlocks.Single().GetText(true),3666 $"Vern: {matchup.CorrelatedBlocks[i].GetText(true)}");3667 }3668 Assert.IsFalse(matchup.CorrelatedBlocks[6].MatchesReferenceText, $"Vern: {matchup.CorrelatedBlocks[6].GetText(true)}");3669 }3670 private static void VerifyCharacterVerseEntriesForRev4V12To13(Block refBlockRev14V12, List<Block> refBlocksRev14V13)3671 {3672 var narrator = CharacterVerseData.GetStandardCharacterId("REV", CharacterVerseData.StandardCharacter.Narrator);3673 Assert.AreEqual("angel flying directly overhead, third", refBlockRev14V12.CharacterId,3674 "Expected pre-condition for test not met. Reference text for REV 14:12 should be a single blockspoken by \"angel flying directly overhead, third\".");3675 Assert.AreEqual(5, refBlocksRev14V13.Count,3676 "Expected pre-condition for test not met. Reference text for REV 14:13 should be 5 blocks.");3677 Assert.AreEqual(narrator, refBlocksRev14V13[0].CharacterId,3678 $"Expected pre-condition for test not met. Reference text block 0 for REV 14:13 should be spoken by \"{narrator}\".");3679 Assert.AreEqual("voice from heaven (God?)", refBlocksRev14V13[1].CharacterId,3680 "Expected pre-condition for test not met. Reference text block 1 for REV 14:13 should be spoken by \"voice from heaven (God?)\".");3681 Assert.AreEqual("Holy Spirit, the", refBlocksRev14V13[2].CharacterId,3682 "Expected pre-condition for test not met. Reference text block 2 for REV 14:13 should be spoken by \"Holy Spirit, the\".");3683 Assert.AreEqual(narrator, refBlocksRev14V13[3].CharacterId,3684 $"Expected pre-condition for test not met. Reference text block 3 for REV 14:13 should be spoken by \"{narrator}\".");3685 Assert.AreEqual("Holy Spirit, the", refBlocksRev14V13[4].CharacterId,3686 "Expected pre-condition for test not met. Reference text block 4 for REV 14:13 should be spoken by \"Holy Spirit, the\".");3687 }3688 #endregion3689 #region PG-1133 (More misalignment between vern and ref)3690 /// <summary>3691 /// This is the text for the MRK 14:70 scenario detailed in PG-1133.3692 /// </summary>3693 [Test]3694 public void GetBlocksForVerseMatchedToReferenceText_VernBlockHasQuoteRenderedAsIndirectSpeech_AllTextFromRefTextIsIncluded()3695 {3696 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3697 var refTextMrk = refText.GetBook("MRK");3698 var refBlocksMrk14V70 = refTextMrk.GetBlocksForVerse(14, 70).ToList();3699 var narrator = CharacterVerseData.GetStandardCharacterId(refTextMrk.BookId, CharacterVerseData.StandardCharacter.Narrator);3700 Assert.AreEqual(4, refBlocksMrk14V70.Count,3701 "Expected pre-condition for test not met. Reference text for MRK 14:70 should be 4 blocks.");3702 Assert.AreEqual(narrator, refBlocksMrk14V70[0].CharacterId,3703 $"Expected pre-condition for test not met. Reference text block 0 for MRK 14:70 should be spoken by \"{narrator}\".");3704 Assert.AreEqual("Peter (Simon)", refBlocksMrk14V70[1].CharacterId,3705 "Expected pre-condition for test not met. Reference text block 1 for MRK 14:70 should be spoken by \"Peter (Simon)\".");3706 Assert.AreEqual(narrator, refBlocksMrk14V70[2].CharacterId,3707 $"Expected pre-condition for test not met. Reference text block 2 for MRK 14:70 should be spoken by \"{narrator}\".");3708 Assert.AreEqual("high priest's servant (relative of the man whose ear Peter cut off)/those standing near", refBlocksMrk14V70[3].CharacterId,3709 "Expected pre-condition for test not met. Reference text block 3 for MRK 14:70 should be spoken by \"high priest's servant (relative of the man whose ear Peter cut off)/those standing near\".");3710 var vernacularBlocks = new List<Block>3711 {3712 new Block("c", 14)3713 {3714 BookCode = refTextMrk.BookId,3715 CharacterId = CharacterVerseData.GetStandardCharacterId(refTextMrk.BookId, CharacterVerseData.StandardCharacter.BookOrChapter),3716 },3717 CreateNarratorBlockForVerse(70, "Navuzwa Petero yambakana kandi.", false, 14, refTextMrk.BookId)3718 };3719 AddNarratorBlockForVerseInProgress(vernacularBlocks, "Lwinyima hakekeke, avandu vaali ni vasingiyi ho vavoolera Petero, ", refTextMrk.BookId).IsParagraphStart = true;3720 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Agiligali oveeye mulala kuvo kigira uturaa Galilaya.»");3721 var vernBook = new BookScript(refTextMrk.BookId, vernacularBlocks, m_vernVersification);3722 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 1);3723 Assert.AreEqual(3, matchup.CorrelatedBlocks.Count);3724 Assert.AreEqual(refBlocksMrk14V70[0].GetText(true) + refBlocksMrk14V70[1].GetText(true),3725 String.Join("", matchup.CorrelatedBlocks[0].ReferenceBlocks.Select(r => r.GetText(true))),3726 $"Vern: {matchup.CorrelatedBlocks[0].GetText(true)}");3727 Assert.AreEqual(refBlocksMrk14V70[2].GetText(true), matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().GetText(true),3728 $"Vern: {matchup.CorrelatedBlocks[1].GetText(true)}");3729 Assert.AreEqual(refBlocksMrk14V70[3].GetText(true), matchup.CorrelatedBlocks[2].ReferenceBlocks.Single().GetText(true),3730 $"Vern: {matchup.CorrelatedBlocks[2].GetText(true)}");3731 }3732 #endregion3733 /// <summary>3734 /// PG-12643735 /// </summary>3736 [Test]3737 public void GetBlocksForVerseMatchedToReferenceText_RefTextVerseStartsWithDirectSpeechButIsIndirectInVern_MatchedByAligningVerseNumbers()3738 {3739 var vernacularBlocks = new List<Block>();3740 vernacularBlocks.Add(CreateNarratorBlockForVerse(1, "Sarvia-machi-Joab, Rey-David Absalónʼgi-nue-binsaed magar daksad. ", true, 14, "2SA")3741 .AddVerse(2, "Degisoggu, Joab ome-emar-binsaed-gaed imaksad. We-ome, Tecoa-neggweburginedid. Joab a-omega sogded:"));3742 AddBlockForVerseInProgress(vernacularBlocks, "Joab", "—An bega, dule-mor-yoleged yoo. Dikasursur dule, be san-sao.");3743 vernacularBlocks.Add(CreateNarratorBlockForVerse(3, "Agi, geb Joab, Rey-Davidʼse barmisad. A-iduale sunmaknai, Rey-Davidʼga sunmakdapoe. ", true, 14, "2SA")3744 .AddVerse(4, "Ome-Tecoa-neggweburgined Rey-David-asabin gwisgunonigua, dulluu-napase imaksad. Davidʼga sogded:"));3745 AddBlockForVerseInProgress(vernacularBlocks, "woman from Tekoa", "—¡Rey, be an-bendake!");3746 var vernBook = new BookScript("2SA", vernacularBlocks, m_vernVersification);3747 var referenceBlocks = new List<Block>();3748 referenceBlocks.Add(CreateNarratorBlockForVerse(1, "Now Joab perceived that the king's heart was toward Absalom.", true, 14, "2SA"));3749 referenceBlocks.Add(CreateNarratorBlockForVerse(2, "Joab sent to Tekoa, fetched a woman, and said,", false, 14, "2SA"));3750 AddBlockForVerseInProgress(referenceBlocks, "Joab", "«Put on mourning clothes, and be as a woman who has mourned a long time.");3751 referenceBlocks.Add(CreateBlockForVerse("Joab", 3, "Go in to the king, and speak thus.»", false, 14));3752 AddNarratorBlockForVerseInProgress(referenceBlocks, "So Joab put the words in her mouth. ", "2SA")3753 .AddVerse(4, "When the woman spoke to the king, she fell on her face to the ground, saying,");3754 referenceBlocks.Last().BookCode = "2SA";3755 AddBlockForVerseInProgress(referenceBlocks, "woman from Tekoa", "«Help, O king!»");3756 var expected = Join("", referenceBlocks.Skip(3).Take(2).Select(r => r.GetText(true)));3757 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3758 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 2);3759 Assert.AreEqual(2, matchup.CorrelatedBlocks.Count);3760 Assert.IsFalse(matchup.CorrelatedBlocks[0].MatchesReferenceText);3761 Assert.IsTrue(matchup.CorrelatedBlocks[1].MatchesReferenceText);3762 Assert.AreEqual(expected,3763 Join("", matchup.CorrelatedBlocks[0].ReferenceBlocks.Select(r => r.GetText(true))));3764 Assert.AreEqual(referenceBlocks.Last().GetText(true), matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().GetText(true));3765 }3766 /// <summary>3767 /// PG-12973768 /// </summary>3769 [Test]3770 public void GetBlocksForVerseMatchedToReferenceText_VernacularHasTextBeforeVerse1InChapter_MatchupDoesNotCrossChapterBoundary()3771 {3772 var vernacularBlocks = new List<Block>();3773 vernacularBlocks.Add(CreateNarratorBlockForVerse(25, "He had no relations with her until she had her firstborn son: and he called him Jesus.", true));3774 vernacularBlocks.Add(NewChapterBlock("MAT", 2));3775 vernacularBlocks.Add(new Block("s", 2) {CharacterId = CharacterVerseData.GetStandardCharacterId("MAT", CharacterVerseData.StandardCharacter.ExtraBiblical)}3776 .AddText("The next thing"));3777 vernacularBlocks.Add(new Block("p", 2) { CharacterId = CharacterVerseData.GetStandardCharacterId("MAT", CharacterVerseData.StandardCharacter.Narrator) }.AddText("The text before verse one:"));3778 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kAmbiguousCharacter, 1, "“Who am I?”", false, 2));3779 var testProject = TestProject.CreateTestProject(TestProject.TestBook.MAT);3780 testProject.Books[0].Blocks = vernacularBlocks;3781 var primaryReferenceText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3782 for (var i = 0; i < vernacularBlocks.Count; i++)3783 {3784 var block = vernacularBlocks[i];3785 if (!block.IsScripture)3786 continue;3787 var matchup = primaryReferenceText.GetBlocksForVerseMatchedToReferenceText(testProject.Books.First(), i);3788 Assert.AreEqual(matchup.OriginalBlocks.First().ChapterNumber, matchup.OriginalBlocks.Last().ChapterNumber);3789 }3790 }3791 /// <summary>3792 /// PG-13153793 /// </summary>3794 [Test]3795 public void GetBlocksForVerseMatchedToReferenceText_VernacularVerseMapsIntoMultiVerseRefBlockInPreviousChapter_MatchupCrossesChapterBoundary()3796 {3797 var testProject = TestProject.CreateTestProject(Resources.OriginalVersification, TestProject.TestBook.NUM);3798 var numbersVern = testProject.GetBook("NUM");3799 var iNum16V35VernBlock = numbersVern.GetIndexOfFirstBlockForVerse(16, 35);3800 var iNum17V1VernBlock = numbersVern.GetIndexOfFirstBlockForVerse(17, 1);3801 Assert.IsTrue(iNum16V35VernBlock < iNum17V1VernBlock);3802 var englishRefText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3803 var numbersEng = englishRefText.GetBook("NUM");3804 var num16V36Block = numbersEng.GetBlocksForVerse(16, 36).Single();3805 if (num16V36Block.InitialStartVerseNumber != 35)3806 {3807 // This is a semi-dangerous hack. Since we can't get the lock, this isn't thread-safe. But most tests don't access NUM, so we're probably okay.3808 var modifiedBooks = (HashSet<string>)ReflectionHelper.GetField(englishRefText, "m_modifiedBooks");3809 modifiedBooks.Add("NUM");3810 var num16V35Block = numbersEng.GetBlocksForVerse(16, 35).Single();3811 num16V36Block.BlockElements.InsertRange(0, num16V35Block.BlockElements);3812 num16V36Block.InitialStartVerseNumber = 35;3813 num16V35Block.BlockElements.Clear();3814 num16V35Block.BlockElements.Add(new ScriptText("This is the new ending for verse thirty-four."));3815 num16V35Block.InitialStartVerseNumber = 34;3816 }3817 var matchup16V35 = englishRefText.GetBlocksForVerseMatchedToReferenceText(numbersVern, iNum16V35VernBlock);3818 var matchup17V1 = englishRefText.GetBlocksForVerseMatchedToReferenceText(numbersVern, iNum17V1VernBlock);3819 Assert.IsTrue(matchup16V35.OriginalBlocks.Select(b => b.GetText(true)).SequenceEqual(matchup17V1.OriginalBlocks.Select(b => b.GetText(true))));3820 }3821 /// <summary>3822 /// PG-1020/PG-1032: Handle case of well-aligned blocks with single quote where vern has verse bridge3823 /// </summary>3824 [Test]3825 public void GetBlocksForVerseMatchedToReferenceText_VernBridgeWithSingleQuoteThatMatchesQuoteInRefText_RefBlocksCombineToMatch()3826 {3827 var vernacularBlocks = new List<Block>();3828 vernacularBlocks.Add(CreateNarratorBlockForVerse(20, "Haxuya ba, ", true, 17, initialEndVerseNumber:21));3829 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "“Hatumingaim haringindi sanga te. Ahatumia: Mastat. Bila balau, ahatum ba longgalo! Bila na bimbia ila.”");3830 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3831 var referenceBlocks = new List<Block>();3832 referenceBlocks.Add(CreateNarratorBlockForVerse(20, "He said to them, ", true, 17));3833 AddBlockForVerseInProgress(referenceBlocks, "Jesus", "“Because of your unbelief. If you have faith, nothing will be impossible. ");3834 referenceBlocks.Add(CreateBlockForVerse("Jesus", 21, "But this kind leaves only by prayer and fasting.”", chapter:17));3835 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);3836 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);3837 var result = matchup.CorrelatedBlocks;3838 Assert.AreEqual(2, result.Count);3839 Assert.IsTrue(vernacularBlocks.Select(b => b.GetText(true)).SequenceEqual(result.Select(b => b.GetText(true))));3840 Assert.AreEqual(referenceBlocks[0].GetText(true), result.First().ReferenceBlocks.Single().GetText(true));3841 Assert.IsTrue(result.All(b => b.MatchesReferenceText));3842 Assert.AreEqual(referenceBlocks[1].GetText(true) + referenceBlocks[2].GetText(true), result.Last().ReferenceBlocks.Single().GetText(true));3843 }3844 3845 #region PG-13933846 [Test]3847 public void GetBlocksForVerseMatchedToReferenceText_VerseBridgeAtEndOfChapterWithTwoNarratorBlocks_OnlyOneVernBlockAlignsToCombinedRefBlocks()3848 {3849 var vernacularBlocks = new List<Block>();3850 vernacularBlocks.Add(CreateNarratorBlockForVerse(20, "Timoteo, cuida bien de no escuchar palabrerías, falsamente llamado " +3851 "“conocimiento de la verdad”; pues algunos se han desviado de la que se te ha confiado fe por creer esa clase de " +3852 "“conocimiento”.", true, 6, "1TI", "p", 21));3853 AddNarratorBlockForVerseInProgress(vernacularBlocks, "Que el Señor derrame su gracia sobre ustedes.", "1TI");3854 var vernBook = new BookScript("1TI", vernacularBlocks, m_vernVersification);3855 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3856 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);3857 var result = matchup.CorrelatedBlocks;3858 Assert.AreEqual(2, result.Count);3859 Assert.IsFalse(result.All(b => b.MatchesReferenceText));3860 var refTextVerses = result.SelectMany(b => b.ReferenceBlocks).SelectMany(r => r.BlockElements.OfType<Verse>()).ToList();3861 Assert.AreEqual(2, refTextVerses.Count);3862 Assert.AreEqual(20, refTextVerses[0].StartVerse);3863 Assert.AreEqual(21, refTextVerses[1].StartVerse);3864 }3865 #endregion3866 #region PG-13943867 [Test]3868 public void GetBlocksForVerseMatchedToReferenceText_HeSaidMatchAtStartOfVerse_AlignedAutomaticallyWithVerseNumberPrepended()3869 {3870 var project = TestProject.CreateTestProject(TestProject.TestBook.MAT);3871 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3872 var mat = project.GetBook("MAT");3873 var iMat21v33 = mat.GetIndexOfFirstBlockForVerse(21, 33);3874 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(mat, iMat21v33, new[] {"Jesús Judío-dummaganga sogdebalid:"});3875 // VERIFY3876 Assert.IsTrue(matchup.CorrelatedBlocks.All(b => b.MatchesReferenceText));3877 var v33 = ((Verse)matchup.CorrelatedBlocks.First().BlockElements.First()).Number;3878 Assert.AreEqual(v33,3879 ((Verse)matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().BlockElements.First()).Number);3880 Assert.IsFalse(matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().BlockElements.OfType<Verse>().Any(v => v.Number == v33));3881 }3882 [Test]3883 public void GetBlocksForVerseMatchedToReferenceText_HeSaidMatchAtStartOfVerseWithDifferentVersification_AlignedAutomaticallyWithCorrespondingVerseNumberPrepended()3884 {3885 var vernacularBlocks = new List<Block>();3886 vernacularBlocks.Add(CreateNarratorBlockForVerse(6, "Continuó: ", false, 32, "GEN"));3887 AddBlockForVerseInProgress(vernacularBlocks, "Jacob (Israel)", "“Tengo animales y gente para tirar para arriba. Vengo en paz.””");3888 var vernBook = new BookScript("GEN", vernacularBlocks, ScrVers.Original);3889 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3890 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, new[] {"Continuó:"});3891 // VERIFY3892 Assert.IsTrue(matchup.CorrelatedBlocks.All(b => b.MatchesReferenceText));3893 Assert.AreEqual("5",3894 ((Verse)matchup.CorrelatedBlocks[0].ReferenceBlocks.Single().BlockElements.First()).Number);3895 Assert.IsFalse(matchup.CorrelatedBlocks[1].ReferenceBlocks.Single().BlockElements.OfType<Verse>().Any());3896 }3897 [Test]3898 public void GetBlocksForVerseMatchedToReferenceText_HeSaidMatchAtEndOfVerse_AlignedAutomatically()3899 {3900 var project = TestProject.CreateTestProject(TestProject.TestBook.MAT);3901 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3902 var mat = project.GetBook("MAT");3903 var iMat8v7 = mat.GetIndexOfFirstBlockForVerse(8, 7);3904 var blocks = mat.GetScriptBlocks();3905 Assert.AreEqual(blocks[iMat8v7].InitialStartVerseNumber, blocks[iMat8v7 + 1].InitialStartVerseNumber,3906 "SETUP check - test data not as expected");3907 Assert.IsTrue(CharacterVerseData.IsCharacterOfType(blocks[iMat8v7].CharacterId, CharacterVerseData.StandardCharacter.Narrator),3908 "SETUP check - test data not as expected");3909 Assert.IsTrue(blocks[iMat8v7].InitialStartVerseNumber < blocks[iMat8v7 + 2].InitialStartVerseNumber,3910 "SETUP check - test data not as expected");3911 var prevBlock = blocks[iMat8v7 + 1];3912 var heSaidBlock = new Block(prevBlock.StyleTag, prevBlock.ChapterNumber,3913 prevBlock.InitialStartVerseNumber, prevBlock.InitialEndVerseNumber)3914 {3915 CharacterId = blocks[iMat8v7].CharacterId,3916 IsParagraphStart = false,3917 BlockElements = new List<BlockElement>(1)3918 };3919 heSaidBlock.BlockElements.Add(new ScriptText(", pregunto-sogde."));3920 mat.Blocks.Insert(iMat8v7 + 2, heSaidBlock);3921 ReflectionHelper.SetField(mat, "m_blockCount", 0); // It's illegal to change block collection, so we have to do this cheat to tell it it's okay.3922 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(mat, iMat8v7, new[] {", pregunto-sogde."});3923 // VERIFY3924 Assert.IsTrue(matchup.CorrelatedBlocks.All(b => b.MatchesReferenceText));3925 Assert.AreEqual(refText.HeSaidText,3926 matchup.CorrelatedBlocks.Last().ReferenceBlocks.Single().GetText(true));3927 }3928 [Test]3929 public void GetBooksWithBlocksConnectedToReferenceText_HeSaidMatchAtStartOfVerse_AlignedAutomaticallyWithVerseNumberPrepended()3930 {3931 var project = TestProject.CreateTestProject(TestProject.TestBook.MAT);3932 project.AddNewReportingClauses(new[] {"Jesús Judío-dummaganga sogdebalid:"});3933 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3934 var matchedUpMat = refText.GetBooksWithBlocksConnectedToReferenceText(project).Single();3935 var iMat21v33 = matchedUpMat.GetIndexOfFirstBlockForVerse(21, 33);3936 var blocks = matchedUpMat.GetScriptBlocks();3937 // VERIFY3938 Assert.IsTrue(blocks[iMat21v33].MatchesReferenceText);3939 Assert.IsTrue(blocks[iMat21v33 + 1].MatchesReferenceText);3940 Assert.AreEqual(((Verse)blocks[iMat21v33].BlockElements.First()).Number,3941 ((Verse)blocks[iMat21v33].ReferenceBlocks.Single().BlockElements.First()).Number);3942 Assert.IsFalse(blocks[iMat21v33 + 1].ReferenceBlocks.Single().ContainsVerseNumber);3943 }3944 #endregion3945 [Test]3946 public void GetBlocksForVerseMatchedToReferenceText_VernBlockSplitAtVerseWhichIsNotSplitInRefText_RefTextSplitToMatchVern()3947 {3948 var vernacularBlocks = new List<Block>();3949 vernacularBlocks.Add(CreateNarratorBlockForVerse(7, "Dadi, pigupokatan nog glupaꞌ nog konaꞌ Hudyu. ", false, 27)3950 .AddVerse(8, "Saꞌan ituꞌ nog Piktolongan nog Duguꞌ. ")3951 .AddVerse(9, "Sog bianbian koni, mituman og inulat ni Dyerimaya nog,"));3952 AddBlockForVerseInProgress(vernacularBlocks, "scripture", "“Inalap nilan og puluꞌ buk solapiꞌ gotow Israꞌel.", "q1");3953 vernacularBlocks.Add(CreateBlockForVerse("scripture", 10, "Bu piksaluy nilan og dondagan nog Mikpongon.”", false, 27, "q1"));3954 vernacularBlocks.Add(new Block("s", 27, 10)3955 {3956 CharacterId = "extra-MAT",3957 BlockElements = new List<BlockElement> (new BlockElement[] {new ScriptText("Piksakan si Isus ni Pilatu") }),3958 });3959 vernacularBlocks.Add(CreateNarratorBlockForVerse(11, "Dangan nilan si Isus diani Pilatu, sinakan non si Isus nog,"));3960 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "“Ika taꞌ og datuꞌ kituꞌ nog bansa Hudyu?” ");3961 AddNarratorBlockForVerseInProgress(vernacularBlocks, "Tinumabal si Isus nog, ");3962 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "“Ika na og miktaluꞌ dun.” ");3963 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3964 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3965 var refTextBlocks = refText.GetBook("MAT").GetBlocksForVerse(27, 9).ToList();3966 Assert.AreEqual(10, refTextBlocks.Last().LastVerseNum,3967 "SETUP check - expected English reference text to have verse 10 included with the last block for MAT 27:9.");3968 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);3969 var result = matchup.CorrelatedBlocks;3970 var scriptureBlocks = result.Where(b => b.CharacterId == "scripture").ToList();3971 Assert.IsTrue(scriptureBlocks.All(b => b.MatchesReferenceText &&3972 b.InitialStartVerseNumber == b.ReferenceBlocks.Single().InitialStartVerseNumber));3973 Assert.AreEqual("10", ((Verse)scriptureBlocks.Last().ReferenceBlocks.Single().BlockElements.First()).Number);3974 }3975 #region PG-1395 (modified for PG-1396 and PG-1403)3976 [TestCase(false)]3977 [TestCase(true)]3978 public void GetBlocksForVerseMatchedToReferenceText_ReportingClausesComeAfterSpeechLinesInVerseWithMultipleSpeakers_AllBlocksMatchedWithReportingClausesMatchedToModifiedReportingClauses(3979 bool blockIsNeedsReview)3980 {3981 var vernacularBlocks = new List<Block>();3982 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 31, "Кьве хцикай бубадин тӀалабун ни кьилиз акъудна?» ", false, 21));3983 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Сад лагьайда», ");3984 var heSaidBlock = AddNarratorBlockForVerseInProgress(vernacularBlocks, "– жаваб гана абуру. ");3985 var narrator = heSaidBlock.CharacterId;3986 if (blockIsNeedsReview)3987 heSaidBlock.CharacterId = CharacterVerseData.kNeedsReview;3988 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«За квез рикӀивай лугьузва: харж кӀватӀдайбурни ява папар Аллагьдин Пачагьлугъдиз квелай вилик акъатда», ");3989 heSaidBlock = AddNarratorBlockForVerseInProgress(vernacularBlocks, "– лагьана Исади. – ");3990 if (blockIsNeedsReview)3991 heSaidBlock.CharacterId = CharacterVerseData.kNeedsReview;3992 var vernBook = new BookScript("MAT", vernacularBlocks, m_vernVersification);3993 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);3994 var refTextBlocks = refText.GetBook("MAT").GetBlocksForVerse(21, 31).ToList();3995 Assert.AreEqual(5, refTextBlocks.Count, "SETUP check - expected English reference text to have five blocks for Matthew 21:31.");3996 Assert.AreEqual("Jesus", refTextBlocks[0].CharacterId,3997 "SETUP check - expected English reference text to have Jesus speak in first block for Luke 7:40.");3998 Assert.IsTrue(refTextBlocks[1].GetText(false).Contains("They said"),3999 "SETUP check - expected English reference text to have reporting clause introducing chief priests/elders");4000 Assert.AreEqual("chief priests/elders", refTextBlocks[2].CharacterId,4001 "SETUP check - expected English reference text to have chief priests/elders speak in response to Jesus' question in Matthew 21:31.");4002 Assert.IsTrue(refTextBlocks[3].GetText(false).Contains("Jesus said"),4003 "SETUP check - expected English reference text to have reporting clause introducing Jesus");4004 Assert.AreEqual("Jesus", refTextBlocks.Last().CharacterId,4005 "SETUP check - expected English reference text to have Jesus speak in final block for Matthew 21:31.");4006 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, new []{"– лагьана ада.", "– лагьана Исади. –", "– минетдалди лагьана ада. –", "– жаваб гана абуру."});4007 var result = matchup.CorrelatedBlocks;4008 Assert.AreEqual(5, result.Count);4009 Assert.IsTrue(result.All(b => b.MatchesReferenceText));4010 var textOfMatchedRefTextBlocks = result.SelectMany(b => b.ReferenceBlocks).Select(r => r.GetText(true)).ToList();4011 Assert.AreEqual(refTextBlocks[0].GetText(true), textOfMatchedRefTextBlocks[0]);4012 Assert.AreEqual(refTextBlocks[2].GetText(true), textOfMatchedRefTextBlocks[1]);4013 Assert.AreEqual(refTextBlocks[1].GetText(true).ToLower().Replace(",", "."), textOfMatchedRefTextBlocks[2].ToLower());4014 Assert.AreEqual(narrator, result[2].CharacterId);4015 Assert.AreEqual(refTextBlocks[4].GetText(true), textOfMatchedRefTextBlocks[3]);4016 Assert.AreEqual(refTextBlocks[3].GetText(true).ToLower().Replace(",", "."), textOfMatchedRefTextBlocks[4].ToLower());4017 Assert.AreEqual(narrator, result[4].CharacterId);4018 }4019 #endregion4020 #region PG-13964021 [Test]4022 public void GetBlocksForVerseMatchedToReferenceText_SimpleReportingClauseComesAfterDialogueInsteadOfBetweenSpeakers_InterveningReportingClauseOmitted()4023 {4024 var vernacularBlocks = new List<Block>();4025 vernacularBlocks.Add(CreateNarratorBlockForVerse(40, "Амма Исади, адахъ элкъвена, лагьана: ", false, 7, "LUK"));4026 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Симун! Захъ ваз лугьудай са гаф ава». ");4027 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "«Лагь, Муаллим», ");4028 AddNarratorBlockForVerseInProgress(vernacularBlocks, "– лагьана ада. ");4029 var vernBook = new BookScript("LUK", vernacularBlocks, m_vernVersification);4030 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4031 var refTextBlocks = refText.GetBook("LUK").GetBlocksForVerse(7, 40).ToList();4032 Assert.AreEqual(4, refTextBlocks.Count, "SETUP check - expected English reference text to have four blocks for Luke 7:40.");4033 Assert.AreEqual("Jesus", refTextBlocks[1].CharacterId,4034 "SETUP check - expected English reference text to have Jesus speak in second block for Luke 7:40.");4035 Assert.IsTrue(((ScriptText)refTextBlocks[1].BlockElements.Single()).Content.TrimEnd().EndsWith("»"),4036 "SETUP check - expected English reference text to have Jesus' words in quotes for Luke 7:40.");4037 Assert.AreEqual(refText.HeSaidText,4038 refTextBlocks[2].GetText(false).ToLower().Replace(",", "."),4039 "SETUP check - expected English reference text to have leading reporting clause between two speakers");4040 Assert.AreEqual("Pharisee (Simon)", refTextBlocks.Last().CharacterId,4041 "SETUP check - expected English reference text to have Pharisee (Simon) speak in final block for Luke 7:40.");4042 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, new []{"– лагьана ада.", "– лагьана Исади. –", "– жаваб гана абуру."});4043 var result = matchup.CorrelatedBlocks;4044 Assert.AreEqual(4, result.Count);4045 Assert.IsTrue(result.All(b => b.MatchesReferenceText));4046 Assert.AreEqual(refTextBlocks[0].GetText(true), result[0].ReferenceBlocks.Single().GetText(true),4047 "Expected the first narrator block in the English reference text to be matched to the first block of matchup for Luke 7:40.");4048 Assert.AreEqual(CharacterVerseData.kAmbiguousCharacter, result[1].CharacterId,4049 "Speaker not expected to be automatically assigned in Jesus' block of matchup for Luke 7:40.");4050 Assert.AreEqual(refTextBlocks[1].GetText(true), result[1].ReferenceBlocks.Single().GetText(true),4051 "Expected the block with Jesus speaking in the English reference text to be matched to the second block of matchup for Luke 7:40.");4052 Assert.AreEqual(CharacterVerseData.kAmbiguousCharacter, result[2].CharacterId,4053 "Speaker not expected to be automatically assigned in Pharisee (Simon)'s block of matchup for Luke 7:40.");4054 Assert.AreEqual(refTextBlocks.Last().GetText(true), result[2].ReferenceBlocks.Single().GetText(true),4055 "Expected the block with Pharisee (Simon) speaking in the English reference text to be matched to the third block of matchup for Luke 7:40.");4056 Assert.AreEqual(refText.HeSaidText, result.Last().ReferenceBlocks.Single().GetText(true),4057 "Expected last block of matchup for Luke 7:40 to match up to a generated \"he said\" block.");4058 }4059 [Test]4060 public void GetBlocksForVerseMatchedToReferenceText_ReportingClauseContainingHeSaidComesAfterSpeechInsteadOfAtStartOfVerse_InterveningReportingClauseOmitted()4061 {4062 var vernacularBlocks = new List<Block>();4063 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 18, "«Заз цӀайлапан хьиз цаварай аватай иблис акуна», ", false, 10));4064 AddNarratorBlockForVerseInProgress(vernacularBlocks, "– лагьана Исади. – ", "LUK");4065 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 19, "«Ингье, За квез гъуьлягърални... ", false, 10));4066 var vernBook = new BookScript("LUK", vernacularBlocks, m_vernVersification);4067 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4068 var refTextBlocks = refText.GetBook("LUK").GetBlocksForVerse(10, 18).ToList();4069 Assert.AreEqual(2, refTextBlocks.Count, "SETUP check - expected English reference text to have two blocks for Luke 10:18.");4070 Assert.AreNotEqual(refTextBlocks[0].StartsAtVerseStart,4071 "SETUP check - expected the first English reference text for Luke 10:18 to start at the beginning of v 18.");4072 var refTextHeSaidLowercase = refText.HeSaidText.ToLower().Trim('.');4073 var refTextActualReportingClauseLowercase = refTextBlocks[0].GetText(false).ToLower();4074 Assert.AreNotEqual(refTextHeSaidLowercase,4075 refTextActualReportingClauseLowercase,4076 "SETUP check - expected the initial reporting clause in the English reference text to have additional words besides \"he said\".");4077 Assert.IsTrue(refTextActualReportingClauseLowercase.Contains(refTextHeSaidLowercase),4078 "SETUP check - expected the initial reporting clause in the English reference text to contain \"he said\".");4079 Assert.AreEqual("Jesus", refTextBlocks[1].CharacterId,4080 "SETUP check - expected English reference text to have Jesus speak in second block for Luke 10:18.");4081 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, new []{"– лагьана ада.", "– лагьана Исади. –", "– жаваб гана абуру."});4082 var result = matchup.CorrelatedBlocks;4083 Assert.AreEqual(2, result.Count);4084 Assert.IsTrue(result.All(b => b.MatchesReferenceText));4085 var firstMatchedRefBlock = result[0].ReferenceBlocks.Single();4086 Assert.IsTrue(firstMatchedRefBlock.StartsAtVerseStart && firstMatchedRefBlock.InitialStartVerseNumber == 18,4087 "Expected the matched reference text of the first block to start with v 18.");4088 Assert.AreEqual("Jesus", result[0].CharacterId);4089 Assert.AreEqual("Jesus", firstMatchedRefBlock.CharacterId);4090 Assert.AreEqual(refTextBlocks[1].GetText(false), firstMatchedRefBlock.GetText(false),4091 "Expected the block with Jesus speaking in the English reference text to be matched to the first block of matchup for Luke 10:18.");4092 var lastMatchedRefBlock = result.Last().ReferenceBlocks.Single();4093 Assert.AreEqual(refTextBlocks[0].CharacterId, lastMatchedRefBlock.CharacterId,4094 "Expected last block of matchup for Luke 10:18 to be spoken by the narrator.");4095 Assert.AreEqual(refTextActualReportingClauseLowercase.Replace(",", "."), lastMatchedRefBlock.GetText(true),4096 "Expected last block of matchup for Luke 10:18 to match up to the modified omitted \"he said\" block.");4097 }4098 [Test]4099 public void GetBlocksForVerseMatchedToReferenceText_ComplexReportingClauseComesAfterSpeechInsteadOfAtStartOfVerse_InterveningReportingClauseOmitted()4100 {4101 var vernacularBlocks = new List<Block>();4102 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 19, "«Чам чпихъ галамай кьван гагьда мехъерин мугьманривай сив хвена акъвазиз жедани?» ", false, 2));4103 AddNarratorBlockForVerseInProgress(vernacularBlocks, "– лагьана Исади. – ", "MRK");4104 var vernBook = new BookScript("MRK", vernacularBlocks, m_vernVersification);4105 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4106 var refTextBlocks = refText.GetBook("MRK").GetBlocksForVerse(2, 19).ToList();4107 Assert.AreEqual(2, refTextBlocks.Count, "SETUP check - expected English reference text to have two blocks for Mark 2:19.");4108 Assert.AreNotEqual(refTextBlocks[0].StartsAtVerseStart,4109 "SETUP check - expected the first English reference text for Mark 2:19 to start at the beginning of v 19.");4110 Assert.AreEqual("Jesus said to them,", refTextBlocks[0].GetText(false).Trim(),4111 "SETUP check - unexpected initial reporting clause in the English reference text.");4112 Assert.AreEqual("Jesus", refTextBlocks[1].CharacterId,4113 "SETUP check - expected English reference text to have Jesus speak in second block for Mark 2:19.");4114 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, new []{"– лагьана ада.", "– лагьана Исади. –", "– жаваб гана абуру."});4115 var result = matchup.CorrelatedBlocks;4116 Assert.AreEqual(2, result.Count);4117 Assert.IsTrue(result.All(b => b.MatchesReferenceText));4118 var firstMatchedRefBlock = result[0].ReferenceBlocks.Single();4119 Assert.IsTrue(firstMatchedRefBlock.StartsAtVerseStart && firstMatchedRefBlock.InitialStartVerseNumber == 19,4120 "Expected the matched reference text of the first block to start with v 19.");4121 Assert.AreEqual("Jesus", result[0].CharacterId);4122 Assert.AreEqual("Jesus", firstMatchedRefBlock.CharacterId);4123 Assert.AreEqual(refTextBlocks[1].GetText(false), firstMatchedRefBlock.GetText(false),4124 "Expected the block with Jesus speaking in the English reference text to be matched to the first block of matchup for Mark 2:19.");4125 var lastMatchedRefBlock = result.Last().ReferenceBlocks.Single();4126 Assert.AreEqual(refTextBlocks[0].CharacterId, lastMatchedRefBlock.CharacterId,4127 "Expected last block of matchup for Mark 2:19 to be spoken by the narrator.");4128 Assert.AreEqual("Jesus said to them.", lastMatchedRefBlock.GetText(true),4129 "Expected last block of matchup for Mark 2:19 to match up to a generated \"he said\" block.");4130 }4131 #endregion4132 #region PG-14034133 // There was a bug that caused the reference text to get changed as a side-effect of4134 // applying the "he said" so that a subsequent retrieval of split locations using4135 // GetVerseSplitLocations could give different results, so that a call to4136 // IsOkayToSplitBeforeBlock that had previously returned true would return false.4137 [Test]4138 public void IsOkayToSplitBeforeBlock_CalledAfterGetBlocksForVerseMatchedToReferenceTextThatAutoMatchesHeSaidAtStartOfVerse_ReturnsTrue()4139 {4140 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.Russian);4141 var firstRussianBlockForMat6v5 = refText.Books.Single(b => b.BookId == "MAT").GetFirstBlockForVerse(6, 5);4142 var russianTextOfFirstBlockForMat6v5 = firstRussianBlockForMat6v5.GetText(true);4143 var englishTextOfFirstBlockForMat6v5 = firstRussianBlockForMat6v5.ReferenceBlocks.Single().GetText(true);4144 var vernacularBlocks = new List<Block>();4145 vernacularBlocks.Add(NewChapterBlock("MAT", 6));4146 vernacularBlocks.Add(CreateBlockForVerse("Jesus", 4, "“Thus your beneficial acts will be executed privately and God, who sees all that is hidden, will give you your trophy.”", true, 6));4147 vernacularBlocks.Add(new Block("s", 6, 4)4148 {4149 CharacterId = "extra-MAT",4150 BlockElements = new List<BlockElement> (new BlockElement[] {new ScriptText("What next?") }),4151 });4152 vernacularBlocks.Add(CreateNarratorBlockForVerse(5, "Jesus continued: ", true, 6));4153 AddBlockForVerseInProgress(vernacularBlocks, "Jesus",4154 "“When you pray, don't babble like a pagan, thinking that you can overwhelm God by sheer volume of words.”")4155 .AddVerse(6, "Instead try praying along these lines: ")4156 .AddVerse(7, "Dearest Holy Father, your name is above all others.");4157 var mat = new BookScript("MAT", vernacularBlocks, m_vernVersification);4158 var iMat6v5 = mat.GetIndexOfFirstBlockForVerse(6, 5);4159 Assert.IsTrue(refText.IsOkayToSplitBeforeBlock(mat,4160 mat.GetScriptBlocks()[iMat6v5], refText.GetVerseSplitLocations("MAT")));4161 refText.GetBlocksForVerseMatchedToReferenceText(mat, iMat6v5, new[] {"Jesus continued:"});4162 // VERIFY4163 Assert.IsTrue(refText.IsOkayToSplitBeforeBlock(mat,4164 mat.GetScriptBlocks()[iMat6v5], refText.GetVerseSplitLocations("MAT")));4165 // Further verify that text of blocks in reference text have not changed:4166 firstRussianBlockForMat6v5 = refText.Books.Single(b => b.BookId == "MAT").GetFirstBlockForVerse(6, 5);4167 Assert.AreEqual(russianTextOfFirstBlockForMat6v5, firstRussianBlockForMat6v5.GetText(true));4168 // This proves that the clone was a deep clone:4169 Assert.AreEqual(englishTextOfFirstBlockForMat6v5, firstRussianBlockForMat6v5.ReferenceBlocks.Single().GetText(true));4170 }4171 #endregion4172 #region PG-14084173 [Test]4174 public void GetBlocksForVerseMatchedToReferenceText_ClosingDashAtStartOfLongHeSaidParagraphNotIdentifiedAsDialogueCloser_NoPartOfReferenceTextDuplicatedNorOmitted()4175 {4176 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4177 var refTextJhn = refText.GetBook("JHN");4178 var refTextBlocksForJhn12V35 = refTextJhn.GetBlocksForVerse(12, 35).ToList();4179 Assert.AreEqual(2, refTextBlocksForJhn12V35.Count, "SETUP check - expected English reference text to have two blocks for John 12:35.");4180 Assert.AreEqual("Jesus", refTextBlocksForJhn12V35[1].CharacterId,4181 "SETUP check - expected English reference text to have Jesus speak in second block for John 12:35.");4182 Assert.AreEqual(35, refTextBlocksForJhn12V35[1].LastVerseNum,4183 "SETUP check - expected English reference text to have have a block break between John 12:35 and v. 36.");4184 var refTextBlocksForJhn12V36 = refTextJhn.GetBlocksForVerse(12, 36).ToList();4185 Assert.AreEqual(2, refTextBlocksForJhn12V36.Count, "SETUP check - expected English reference text to have two blocks for John 12:36.");4186 Assert.AreEqual("Jesus", refTextBlocksForJhn12V36[0].CharacterId,4187 "SETUP check - expected English reference text to have Jesus speak in the first block for John 12:36.");4188 Assert.IsTrue(CharacterVerseData.IsCharacterOfType(refTextBlocksForJhn12V36[1].CharacterId,4189 CharacterVerseData.StandardCharacter.Narrator),4190 "SETUP check - expected English reference text to have the narrator speak in the second block for John 12:36.");4191 var matchup = GetBlockMatchupForJohn12V35And36ForPg1408();4192 var result = matchup.CorrelatedBlocks;4193 Assert.AreEqual(4, result.Count);4194 Assert.IsTrue(result[0].MatchesReferenceText);4195 Assert.IsTrue(result[1].MatchesReferenceText);4196 Assert.IsTrue(result[2].MatchesReferenceText);4197 Assert.IsFalse(result[3].MatchesReferenceText);4198 Assert.AreEqual(refTextBlocksForJhn12V35[0].GetText(true), result[0].ReferenceBlocks.Single().GetText(true),4199 "Expected the first narrator block in the English reference text for John 12:35 to be matched to the first block of matchup.");4200 Assert.AreEqual(refTextBlocksForJhn12V35[1].GetText(true), result[1].ReferenceBlocks.Single().GetText(true),4201 "Expected the second block (Jesus) in the English reference text for John 12:35 to be matched to the second block of matchup.");4202 Assert.AreEqual(refTextBlocksForJhn12V36[0].GetText(true), result[2].ReferenceBlocks.Single().GetText(true),4203 "Expected the first block (Jesus) in the English reference text for John 12:36 to be matched to the third block of matchup.");4204 Assert.AreEqual(refTextBlocksForJhn12V36[1].GetText(true), result[3].ReferenceBlocks.Single().GetText(true),4205 "Expected the second block (narrator) in the English reference text for John 12:36 to be correlated (but not matched) to the last block of matchup.");4206 }4207 internal static BlockMatchup GetBlockMatchupForJohn12V35And36ForPg1408()4208 {4209 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4210 var vernacularBlocks = new List<Block>();4211 vernacularBlocks.Add(CreateNarratorBlockForVerse(35, "ꞌBa Jesús kitsure:", true, 12, "JHN"));4212 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "—Tu ngichuba nixtjin kꞌuejñajin ngisanu ndiꞌu. Ngatꞌa xi ña jñu tsuꞌba bi be ñá fi. ")4213 .AddVerse(36, "Ngatjamakjainnu ngatꞌare ndiꞌu yejerañu tjin ngisanu, tuxi tseꞌe ndiꞌu ku̱anñu");4214 // The following is supposed to be spoken by the narrator, but the "closing" dash at the start of the4215 // paragraph is treated as an opener.4216 AddBlockForVerseInProgress(vernacularBlocks, "Jesus", "—kitsu Jesús, ꞌba ꞌbatsaꞌen ꞌetju ꞌba tsikꞌejñaꞌmore xutankjiun.")4217 .IsParagraphStart = true;4218 var vernBook = new BookScript("JHN", vernacularBlocks, refText.Versification);4219 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4220 return matchup;4221 }4222 [TestCase(ReferenceTextType.English)]4223 [TestCase(ReferenceTextType.Russian)]4224 public void GetBlocksForVerseMatchedToReferenceText_ClosingDashAtStartOfShortHeSaidParagraphNotIdentifiedAsDialogueCloser_NoPartOfReferenceTextDuplicatedNorOmitted(4225 ReferenceTextType type)4226 {4227 var narrator = CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Narrator);4228 var refText = ReferenceText.GetStandardReferenceText(type);4229 var refTextMrk = refText.GetBook("MRK");4230 var refTextBlocksForMrk15V14 = refTextMrk.GetBlocksForVerse(15, 14).ToList();4231 Assert.AreEqual(4, refTextBlocksForMrk15V14.Count, "SETUP check - expected reference text to have four blocks for Mark 15:14.");4232 Assert.AreEqual(narrator, refTextBlocksForMrk15V14[0].CharacterId,4233 "SETUP check - expected reference text to have narrator speak in first block for Mark 15:14.");4234 Assert.AreEqual("Pilate", refTextBlocksForMrk15V14[1].CharacterId,4235 "SETUP check - expected reference text to have Pilate speak in second block for Mark 15:14.");4236 Assert.AreEqual(narrator, refTextBlocksForMrk15V14[2].CharacterId,4237 "SETUP check - expected reference text to have narrator speak in third block for Mark 15:14.");4238 Assert.AreEqual("crowd before Pilate", refTextBlocksForMrk15V14[3].CharacterId,4239 "SETUP check - expected reference text to have the crowd before Pilate speak in last block for Mark 15:14.");4240 Assert.AreEqual(14, refTextBlocksForMrk15V14.Last().LastVerseNum,4241 "SETUP check - expected reference text to have have a block break between Mark 15:14 and v. 15.");4242 var vernacularBlocks = new List<Block>();4243 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kAmbiguousCharacter, 14,4244 "—Tunga ¿mé= kjua xi chꞌotjin xi kitsaꞌen kui?", true, 15));4245 // The following is supposed to be spoken by the narrator, but the "closing" dash at the start of the4246 // paragraph is treated as an opener.4247 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter,4248 "—kitsingojo Pilato.");4249 AddNarratorBlockForVerseInProgress(vernacularBlocks, "Tunga xutankjiun ngisa ꞌñu kiskiꞌndaya ꞌba kitsu:", "MRK");4250 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter,4251 "—¡Tjatꞌai kru!");4252 var vernBook = new BookScript("MRK", vernacularBlocks, refText.Versification);4253 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4254 var result = matchup.CorrelatedBlocks;4255 Assert.AreEqual(4, result.Count);4256 Assert.AreEqual("14", ((Verse)result[0].BlockElements[0]).Number);4257 Assert.IsFalse(result.Take(2).All(b => b.MatchesReferenceText),4258 "One or both of the first two blocks should not match the reference text.");4259 Assert.IsTrue(result[2].MatchesReferenceText);4260 Assert.IsTrue(result[3].MatchesReferenceText);4261 var allReferenceBlocks = result.SelectMany(b => b.ReferenceBlocks).ToList();4262 Assert.AreEqual(4, allReferenceBlocks.Count,4263 "There should be no extra or missing reference blocks");4264 Assert.IsTrue(refTextBlocksForMrk15V14.Select(b => b.CharacterId)4265 .SetEquals(allReferenceBlocks.Select(b => b.CharacterId)),4266 "The resulting reference blocks should have the same characters as the original reference blocks");4267 var blockComparer = new BlockComparer();4268 Assert.AreEqual(4, allReferenceBlocks.Distinct(blockComparer).Count(),4269 "There should be no duplicate reference blocks");4270 Assert.AreEqual(14, allReferenceBlocks.Single(b => b.StartsAtVerseStart).BlockElements.OfType<Verse>().Single().AllVerseNumbers.Single());4271 var indexOfPrevRefBlockInOriginalList = -1;4272 foreach (var nonPilateSaidRefBlock in refTextBlocksForMrk15V14.Skip(1))4273 {4274 var indexOfThisRefBlockInResult = allReferenceBlocks.FindIndex(b => blockComparer.Equals(b, nonPilateSaidRefBlock));4275 Assert.IsTrue(indexOfThisRefBlockInResult >= 0,4276 $"Reference block {nonPilateSaidRefBlock} missing. With the possible exception of" +4277 $" the \"he said\" block for Pilate, all reference blocks should be in the" +4278 $" list of blocks corresponding to a vernacular block.");4279 Assert.IsTrue(indexOfThisRefBlockInResult >= indexOfPrevRefBlockInOriginalList,4280 $"Reference block {nonPilateSaidRefBlock} out of order. With the possible exception" +4281 $" of the \"he said\" block for Pilate, all reference blocks should be in the" +4282 $" same relative order as their occur in the reference text.");4283 indexOfPrevRefBlockInOriginalList = indexOfThisRefBlockInResult;4284 if (refText.HasSecondaryReferenceText)4285 {4286 var refBlockInOrigList = allReferenceBlocks[indexOfThisRefBlockInResult].ReferenceBlocks.Single();4287 var refBlockInResults = nonPilateSaidRefBlock.ReferenceBlocks.Single();4288 Assert.IsTrue(blockComparer.Equals(refBlockInOrigList, refBlockInResults),4289 "Secondary (English) reference text got hooked up differently from the primary!");4290 }4291 }4292 if (refText.HasSecondaryReferenceText)4293 {4294 Assert.AreEqual(14, allReferenceBlocks.Select(b => b.ReferenceBlocks.Single()).Single(b => b.StartsAtVerseStart)4295 .BlockElements.OfType<Verse>().Single().AllVerseNumbers.Single());4296 var firstRefBlock = allReferenceBlocks[0];4297 Assert.IsTrue(firstRefBlock.MatchesReferenceText);4298 var secondaryRefBlock = firstRefBlock.ReferenceBlocks.Single();4299 Assert.AreEqual(firstRefBlock.StartsAtVerseStart, secondaryRefBlock.StartsAtVerseStart);4300 Assert.AreEqual(firstRefBlock.InitialStartVerseNumber, secondaryRefBlock.InitialStartVerseNumber);4301 Assert.AreEqual(firstRefBlock.LastVerseNum, secondaryRefBlock.LastVerseNum);4302 }4303 }4304 [TestCase(ReferenceTextType.English)]4305 [TestCase(ReferenceTextType.Russian)]4306 public void GetBlocksForVerseMatchedToReferenceText_ClosingDashAtStartOfShortHeSaidParagraphNotIdentifiedAsDialogueCloserInSameOrderAsRefText_UnmodifiedRefBlocksAlignedWithOneUnmatched(4307 ReferenceTextType type)4308 {4309 var narrator = CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Narrator);4310 var refText = ReferenceText.GetStandardReferenceText(type);4311 var refTextMrk = refText.GetBook("MRK");4312 var refTextBlocksForMrk10V39And40 = refTextMrk.GetBlocksForVerse(10, 39).ToList();4313 Assert.AreEqual(4, refTextBlocksForMrk10V39And40.Count, "SETUP check - expected reference text to have four blocks for Mark 10:39.");4314 Assert.AreEqual(narrator, refTextBlocksForMrk10V39And40[0].CharacterId,4315 "SETUP check - expected reference text to have narrator speak in first block for Mark 10:39.");4316 Assert.AreEqual("James, the disciple/John", refTextBlocksForMrk10V39And40[1].CharacterId,4317 "SETUP check - expected reference text to have James and John speak in second block for Mark 10:39.");4318 Assert.AreEqual(narrator, refTextBlocksForMrk10V39And40[2].CharacterId,4319 "SETUP check - expected reference text to have narrator speak in third block for Mark 10:39.");4320 Assert.AreEqual("Jesus", refTextBlocksForMrk10V39And40[3].CharacterId,4321 "SETUP check - expected reference text to have Jesus speak in last block for Mark 10:39.");4322 Assert.AreEqual(39, refTextBlocksForMrk10V39And40.Last().LastVerseNum,4323 "SETUP check - expected reference text to have have a block break between Mark 10:39 and v. 40.");4324 var refTextBlocksForMrk10V40 = refTextMrk.GetBlocksForVerse(10, 40).Single();4325 Assert.AreEqual("Jesus", refTextBlocksForMrk10V40.CharacterId,4326 "SETUP check - expected reference text to have Jesus speak in block for Mark 10:40.");4327 Assert.AreEqual("40", refTextBlocksForMrk10V40.BlockElements.OfType<Verse>().Single().Number,4328 "SETUP check - expected reference text to have have a block break between Mark 10:40 and v. 41.");4329 refTextBlocksForMrk10V39And40.Add(refTextBlocksForMrk10V40);4330 var vernacularBlocks = new List<Block>();4331 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kAmbiguousCharacter, 39,4332 "—Ku̱an=ni", true, 10));4333 // The following is supposed to be spoken by the narrator, but the "closing" dash at the start of the4334 // paragraph is treated as an opener.4335 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter,4336 "—kitsingojo ngojó.");4337 AddNarratorBlockForVerseInProgress(vernacularBlocks, "ꞌBa Jesús kitsure:", "MRK");4338 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter,4339 "—Sꞌiu nda sja xi kꞌuia̱ an, ꞌba sa̱tendo ko kjuanima jotsaꞌen sa̱tendaa̱; ")4340 .AddVerse(40, "tunga tsa ngate kixina̱ asa ngate skjunna̱ kuetsubo, tu kui= xuta xi je kisꞌendare ngaꞌndebiu kuaꞌere.");4341 var vernBook = new BookScript("MRK", vernacularBlocks, refText.Versification);4342 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4343 var result = matchup.CorrelatedBlocks;4344 Assert.AreEqual(5, result.Count);4345 Assert.AreEqual("39", ((Verse)result[0].BlockElements[0]).Number);4346 Assert.IsFalse(result.Take(2).All(b => b.MatchesReferenceText),4347 "One or both of the first two blocks should not match the reference text.");4348 Assert.IsTrue(result[2].MatchesReferenceText);4349 Assert.IsTrue(result[3].MatchesReferenceText);4350 Assert.IsTrue(result[4].MatchesReferenceText);4351 var allReferenceBlocks = result.SelectMany(b => b.ReferenceBlocks).ToList();4352 Assert.AreEqual(5, allReferenceBlocks.Count,4353 "There should be no extra or missing reference blocks");4354 Assert.IsTrue(refTextBlocksForMrk10V39And40.Select(b => b.CharacterId)4355 .SetEquals(allReferenceBlocks.Select(b => b.CharacterId)),4356 "The resulting reference blocks should have the same characters as the original reference blocks");4357 var blockComparer = new BlockComparer();4358 Assert.AreEqual(5, allReferenceBlocks.Distinct(blockComparer).Count(),4359 "There should be no duplicate reference blocks");4360 Assert.IsTrue(allReferenceBlocks.SelectMany(b => b.BlockElements).OfType<Verse>().Select(v => v.Number)4361 .SetEquals(new [] {"39", "40"}));4362 Assert.IsTrue(allReferenceBlocks.SequenceEqual(refTextBlocksForMrk10V39And40, blockComparer));4363 if (refText.HasSecondaryReferenceText)4364 {4365 Assert.IsTrue(allReferenceBlocks.All(b => b.MatchesReferenceText));4366 var englishRefBlocks = allReferenceBlocks.Select(b => b.ReferenceBlocks.Single()).ToList();4367 Assert.AreEqual(5, englishRefBlocks.Distinct(blockComparer).Count(),4368 "There should be no duplicate English reference blocks");4369 Assert.IsTrue(englishRefBlocks.SelectMany(b => b.BlockElements).OfType<Verse>().Select(v => v.Number)4370 .SetEquals(new [] {"39", "40"}));4371 Assert.IsTrue(englishRefBlocks.SequenceEqual(refTextBlocksForMrk10V39And40.Select(b => b.ReferenceBlocks.Single()), blockComparer));4372 }4373 }4374 [TestCase(ReferenceTextType.English)]4375 [TestCase(ReferenceTextType.Russian)]4376 public void GetBlocksForVerseMatchedToReferenceText_InterruptingDashForHeSaidParagraphNotIdentifiedAsDialogueCloserInVerseWithSingleSpeaker_HeSaidNotOmitted(4377 ReferenceTextType type)4378 {4379 var narrator = CharacterVerseData.GetStandardCharacterId("MAT", CharacterVerseData.StandardCharacter.Narrator);4380 var refText = ReferenceText.GetStandardReferenceText(type);4381 var refTextMat = refText.GetBook("MAT");4382 var refTextBlocksForMat19V20 = refTextMat.GetBlocksForVerse(19, 20).ToList();4383 Assert.AreEqual(2, refTextBlocksForMat19V20.Count, "SETUP check - expected reference text to have two blocks for Matthew 19:20.");4384 Assert.AreEqual(narrator, refTextBlocksForMat19V20[0].CharacterId,4385 "SETUP check - expected reference text to have narrator speak in first block for Matthew 19:20.");4386 Assert.AreEqual("rich young ruler", refTextBlocksForMat19V20[1].CharacterId,4387 "SETUP check - expected reference text to have the rich young ruler speak in second block for Matthew 19:20.");4388 Assert.AreEqual(20, refTextBlocksForMat19V20.Last().LastVerseNum,4389 "SETUP check - expected reference text to have have a block break between Matthew 19:20 and v. 21.");4390 var vernacularBlocks = new List<Block>();4391 vernacularBlocks.Add(CreateBlockForVerse(refTextBlocksForMat19V20[1].CharacterId, 20,4392 "—Ngayéjebiu je kitsikꞌetjusaa̱n", true, 19));4393 // The following is supposed to be spoken by the narrator, but the "closing" (interrupting) dash at the4394 // start of the paragraph is treated as an opener.4395 AddBlockForVerseInProgress(vernacularBlocks, refTextBlocksForMat19V20[1].CharacterId,4396 "—kitsu chanaꞌenbiu");4397 AddBlockForVerseInProgress(vernacularBlocks, refTextBlocksForMat19V20[1].CharacterId,4398 "—. ¿Mé= xi chaja ngisana̱?");4399 var vernBook = new BookScript("MAT", vernacularBlocks, refText.Versification);4400 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4401 var result = matchup.CorrelatedBlocks;4402 Assert.AreEqual(3, result.Count);4403 Assert.AreEqual("20", ((Verse)result[0].BlockElements[0]).Number);4404 Assert.IsFalse(result.All(b => b.MatchesReferenceText),4405 "At least one of the blocks should not match the reference text.");4406 var allReferenceBlocks = result.SelectMany(b => b.ReferenceBlocks).ToList();4407 Assert.IsTrue(allReferenceBlocks.Any(b => b.CharacterId == narrator),4408 "The narrator block with the reporting clause should not be omitted.");4409 var blockComparer = new BlockComparer();4410 Assert.IsTrue(allReferenceBlocks.Contains(refTextBlocksForMat19V20[1], blockComparer),4411 "The reference block spoken by the rich young ruler should not be omitted.");4412 Assert.AreEqual("20", ((Verse)allReferenceBlocks[0].BlockElements.First()).Number);4413 if (refText.HasSecondaryReferenceText)4414 {4415 Assert.That(allReferenceBlocks.All(b => b.MatchesReferenceText));4416 Assert.AreEqual("20", ((Verse)allReferenceBlocks.Select(b => b.ReferenceBlocks.Single()).First().BlockElements.First()).Number);4417 }4418 }4419 #endregion4420 #region PG-14234421 [TestCase(true)]4422 [TestCase(false)]4423 public void GetBlocksForVerseMatchedToReferenceText_OpeningAndClosingReportingClausesInVerseThatIsAllQuotationInEnglishReferenceText_EntireReferenceTextAssociatedWithQuoteBlock(4424 bool includeClosingHeSaidInReportingClauses)4425 {4426 ReferenceText refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4427 var refTextMat = refText.GetBook("MAT");4428 var refTextBlockForMat2V19 = refTextMat.GetBlocksForVerse(2, 19).Single();4429 Assert.IsTrue(CharacterVerseData.IsCharacterOfType(refTextBlockForMat2V19.CharacterId, CharacterVerseData.StandardCharacter.Narrator),4430 "SETUP check - expected English reference text to have narrator speak in block for Mat 2:19.");4431 Assert.AreEqual(19, refTextBlockForMat2V19.LastVerseNum,4432 "SETUP check - expected English reference text to have have a block break between Mat 2:19 and v. 20.");4433 var refTextBlockForMat2V20 = refTextMat.GetBlocksForVerse(2, 20).Last();4434 Assert.AreEqual("angel", refTextBlockForMat2V20.CharacterId,4435 "SETUP check - expected English reference text to have angel speak in block for Mat 2:20.");4436 Assert.AreEqual(20, refTextBlockForMat2V20.LastVerseNum,4437 "SETUP check - expected English reference text to have have a block break between Mat 2:20 and v. 21.");4438 var matchup = GetBlockMatchupForMat2V20(includeClosingHeSaidInReportingClauses, refTextBlockForMat2V20, refText);4439 var result = matchup.CorrelatedBlocks;4440 Assert.AreEqual(4, result.Count);4441 Assert.IsTrue(result[0].MatchesReferenceText);4442 Assert.IsFalse(result[1].MatchesReferenceText);4443 Assert.IsTrue(result[2].MatchesReferenceText);4444 Assert.AreEqual(includeClosingHeSaidInReportingClauses, result[3].MatchesReferenceText);4445 Assert.AreEqual(refTextBlockForMat2V19.GetText(true), result[0].ReferenceBlocks.Single().GetText(true),4446 "Expected the narrator block in the English reference text for Mat 2:19 to be matched to the first block of matchup.");4447 Assert.AreEqual(refTextBlockForMat2V20.GetText(true), result[2].ReferenceBlocks.Single().GetText(true),4448 "Expected the block (angel) in the English reference text for Mat 2:20 to be matched to the third block of matchup.");4449 }4450 private static BlockMatchup GetBlockMatchupForMat2V20(bool includeClosingHeSaidInReportingClauses, Block refTextBlockForMat2V20, ReferenceText refText)4451 {4452 var vernacularBlocks = new List<Block>();4453 vernacularBlocks.Add(CreateNarratorBlockForVerse(19,4454 "Apnengkek mokhom Jose m'a iokhalhma Egipto, apveske Herodes. Neksa apteianma lhnak Jose m'a,mokhom angel apkapaskama Apveske,", true, 2)4455 .AddVerse(20, "lhna aptemak:"));4456 // The following is supposed to be spoken by the narrator, but the "closing" (interrupting) dash at the4457 // start of the paragraph is treated as an opener.4458 AddBlockForVerseInProgress(vernacularBlocks, refTextBlockForMat2V20.CharacterId,4459 "—¡Elhatakha, eiantemekha nematka nak kakpota nhan ngken akieto Israel, apkenmaskengvakme apkenmahai'a lhta ennapok nematka nak! ")4460 .Delivery = refTextBlockForMat2V20.Delivery;4461 var closingHeSaid = AddNarratorBlockForVerseInProgress(vernacularBlocks, "—lhna aptemak.");4462 var vernBook = new BookScript("MAT", vernacularBlocks, refText.Versification);4463 var reportingClauses = new List<string>(new[] {"— lhna aptemak ma'a.", "lhna aptemak ma'a.", "lhna aptemak."});4464 if (includeClosingHeSaidInReportingClauses)4465 reportingClauses.Insert(2, "—lhna aptemak.");4466 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, reportingClauses);4467 return matchup;4468 }4469 [TestCase(true)]4470 [TestCase(false)]4471 public void GetBlocksForVerseMatchedToReferenceText_OpeningAndClosingReportingClausesInVerseThatIsAllQuotationInReferenceText_EntireReferenceTextAssociatedWithQuoteBlock(4472 bool includeClosingHeSaidInReportingClauses)4473 {4474 ReferenceText refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.Russian);4475 var refTextMat = refText.GetBook("MAT");4476 var refTextBlockForMat2V19 = refTextMat.GetBlocksForVerse(2, 19).Single();4477 Assert.IsTrue(CharacterVerseData.IsCharacterOfType(refTextBlockForMat2V19.CharacterId, CharacterVerseData.StandardCharacter.Narrator),4478 "SETUP check - expected Russian reference text to have narrator speak in block for Mat 2:19.");4479 Assert.AreEqual(20, refTextBlockForMat2V19.LastVerseNum,4480 "SETUP check - expected Russian reference text to have have the start of Mat 2:20 included in block for v. 19.");4481 var refTextBlockForMat2V20 = refTextMat.GetBlocksForVerse(2, 20).Last();4482 Assert.AreEqual("angel", refTextBlockForMat2V20.CharacterId,4483 "SETUP check - expected Russian reference text to have angel speak in block for Mat 2:20.");4484 Assert.AreEqual(20, refTextBlockForMat2V20.LastVerseNum,4485 "SETUP check - expected Russian reference text to have have a block break between Mat 2:20 and v. 21.");4486 var matchup = GetBlockMatchupForMat2V20(includeClosingHeSaidInReportingClauses, refTextBlockForMat2V20, refText);4487 var result = matchup.CorrelatedBlocks;4488 Assert.AreEqual(3, result.Count);4489 Assert.IsTrue(result[0].MatchesReferenceText);4490 Assert.IsTrue(result[1].MatchesReferenceText);4491 Assert.AreEqual(includeClosingHeSaidInReportingClauses, result[2].MatchesReferenceText);4492 Assert.AreEqual(refTextBlockForMat2V19.GetText(true), result[0].ReferenceBlocks.Single().GetText(true),4493 "Expected the narrator block in the reference text for Mat 2:19 to be matched to the first block of matchup.");4494 Assert.AreEqual(refTextBlockForMat2V20.GetText(true), result[1].ReferenceBlocks.Single().GetText(true),4495 "Expected the block (angel) in the reference text for Mat 2:20 to be matched to the third block of matchup.");4496 }4497 #endregion4498 #region PG-14314499 [TestCase(ReferenceTextType.English)]4500 [TestCase(ReferenceTextType.Russian)]4501 public void GetBlocksForVerseMatchedToReferenceText_ReportingClausesInRefTextAppearBetweenSpeakingPartsInVern_RefTextReportingClausesCombinedToMatchOnlyNarratorBlock(4502 ReferenceTextType refTextType)4503 {4504 var refText = ReferenceText.GetStandardReferenceText(refTextType);4505 var refTextJhn = refText.GetBook("JHN");4506 var refTextBlocksJhn8V11 = refTextJhn.GetBlocksForVerse(8, 11).ToList();4507 Assert.AreEqual(4, refTextBlocksJhn8V11.Count,4508 "SETUP check - unexpected number of reference blocks for John 8:11.");4509 Assert.AreEqual("woman, caught in adultery", refTextBlocksJhn8V11[1].CharacterId,4510 $"SETUP check - expected {refTextType} reference text to have woman speak in second block for John 8:11.");4511 Assert.AreEqual("Jesus", refTextBlocksJhn8V11[3].CharacterId,4512 $"SETUP check - expected {refTextType} reference text to have Jesus speak in last block for John 8:11.");4513 var vernacularBlocks = new List<Block>();4514 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kAmbiguousCharacter, 11, "“Ondaꞌidun, Polopanad,” ", true, 8));4515 AddNarratorBlockForVerseInProgress(vernacularBlocks, "tinumabal og glibun koyon. Miktaluꞌ si Isus, ", "JHN");4516 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter, "“Akon siꞌoy ondiꞌu ika ukumon. Uliꞌa na bu naꞌa na mokpuliꞌ moginang nog dusa.”");4517 var vernBook = new BookScript("JHN", vernacularBlocks, refText.Versification);4518 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4519 var result = matchup.CorrelatedBlocks;4520 Assert.AreEqual(3, result.Count);4521 Assert.IsTrue(result[0].MatchesReferenceText);4522 Assert.IsFalse(result[1].MatchesReferenceText);4523 Assert.IsTrue(result[2].MatchesReferenceText);4524 var womanRefBlock = result[0].ReferenceBlocks.Single();4525 Assert.IsTrue(womanRefBlock.StartsAtVerseStart);4526 Assert.AreEqual(result[0].InitialStartVerseNumber, womanRefBlock.InitialStartVerseNumber);4527 Assert.AreEqual(4528 refTextBlocksJhn8V11.Single(b => b.CharacterId == "woman, caught in adultery").GetText(false),4529 womanRefBlock.GetText(false),4530 $"Expected the second block (woman in adultery) in the {refTextType} reference text for" +4531 " John 8:11 to be matched to the first block of matchup.");4532 if (refText.HasSecondaryReferenceText)4533 {4534 womanRefBlock = womanRefBlock.ReferenceBlocks.Single();4535 Assert.IsTrue(womanRefBlock.StartsAtVerseStart);4536 Assert.AreEqual(result[0].InitialStartVerseNumber, womanRefBlock.InitialStartVerseNumber);4537 Assert.AreEqual(4538 refTextBlocksJhn8V11.Single(b => b.CharacterId == "woman, caught in adultery").GetPrimaryReferenceText(true),4539 womanRefBlock.GetText(false),4540 $"Expected the second block (woman in adultery) in the {refTextType} reference text for" +4541 " John 8:11 to be matched to the first block of matchup.");4542 }4543 Assert.AreEqual(2, result[1].ReferenceBlocks.Count);4544 Assert.AreEqual(refTextBlocksJhn8V11.First(b => !b.IsQuote).GetText(false),4545 result[1].ReferenceBlocks[0].GetText(true),4546 "Expected the first reporting clause in the reference text for John 8:11 to be the " +4547 "first reference block for the combined reporting clause block in the vernacular.");4548 Assert.AreEqual(refTextBlocksJhn8V11.Last(b => !b.IsQuote).GetText(false),4549 result[1].ReferenceBlocks[1].GetText(true),4550 "Expected the last reporting clause in the reference text for John 8:11 to be the " +4551 "last reference block for the combined reporting clause block in the vernacular.");4552 Assert.AreEqual(4553 refTextBlocksJhn8V11.Single(b => b.CharacterId == "Jesus").GetText(true),4554 result[2].ReferenceBlocks.Single().GetText(false),4555 $"Expected the \"Jesus\" block in the {refTextType} reference text for" +4556 " John 8:11 to be matched to the last block of matchup.");4557 }4558 #endregion4559 #region PG-14084560 [TestCase()]4561 [TestCase("– диэн көрдөспүтэ")]4562 public void GetBlocksForVerseMatchedToReferenceText_MultipleReportingClausesInOppositeOrder_NoReferenceTextIsLost(4563 params string[] knownHeSaids)4564 {4565 var refText = ReferenceText.GetStandardReferenceText(ReferenceTextType.English);4566 var refTextMat = refText.GetBook("MAT");4567 var refTextBlocksMat15V34 = refTextMat.GetBlocksForVerse(15, 34).ToList();4568 Assert.AreEqual(4, refTextBlocksMat15V34.Count,4569 "SETUP check - unexpected number of reference blocks for Matthew 15:34.");4570 Assert.AreEqual("Jesus", refTextBlocksMat15V34[1].CharacterId,4571 "SETUP check - expected English reference text to have Jesus speak in second block for Matthew 15:34.");4572 Assert.AreEqual("disciples", refTextBlocksMat15V34[3].CharacterId,4573 "SETUP check - expected English reference text to have disciples speak in last block for Matthew 15:34.");4574 4575 var refTextBlocksMat15V35 = refTextMat.GetBlocksForVerse(15, 35).ToList();4576 Assert.AreEqual(2, refTextBlocksMat15V35.Count,4577 "SETUP check - unexpected number of reference blocks for Matthew 15:35.");4578 Assert.AreEqual("Jesus", refTextBlocksMat15V35[1].CharacterId,4579 "SETUP check - expected English reference text to have Jesus speak in second block for Matthew 15:35.");4580 for (int v = 36; v <= 39; v++)4581 {4582 Assert.IsTrue(refTextMat.GetBlocksForVerse(15, v).Single()4583 .CharacterIs("MAT", CharacterVerseData.StandardCharacter.Narrator),4584 $"SETUP check - expected single narrator block in English reference text for Matthew 15:{v}");4585 }4586 var vernacularBlocks = new List<Block>();4587 vernacularBlocks.Add(CreateBlockForVerse(CharacterVerseData.kAmbiguousCharacter, 34,4588 "«Эһиги төһө килиэптээххитий?»", true, 15));4589 AddNarratorBlockForVerseInProgress(vernacularBlocks, "– Иисус ыйыппыта.");4590 vernacularBlocks.Last().IsParagraphStart = true;4591 AddBlockForVerseInProgress(vernacularBlocks, CharacterVerseData.kAmbiguousCharacter,4592 "«Сэттэ килиэби кытта аҕыйах кыра балык баар»,");4593 vernacularBlocks.Last().IsParagraphStart = true;4594 AddNarratorBlockForVerseInProgress(vernacularBlocks, "– диэбиттэрэ. ")4595 .AddVerse(35, "Кини дьону сиргэ олордубута. ")4596 .AddVerse(36, "Онтон сэттэ килиэби уонна балыгы ылан, үөрэнээччилэрэ дьоҥҥо үллэрбиттэрэ. ")4597 .AddVerse(37, "Бары тото аһаабыттара; хаалбыт астара сэттэ толору корзина буолбута. ")4598 .AddVerse(38, "Манна оҕону-дьахтары таһынан барыта түөрт тыһыынча эр киһи аһаабыта. ")4599 .AddVerse(39, "Онтон дьону ыыталаан баран, Иисус оҥочоҕо олорон, Магдала сиригэр устубута.");4600 vernacularBlocks.Last().IsParagraphStart = true;4601 var vernBook = new BookScript("MAT", vernacularBlocks, refText.Versification);4602 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, knownHeSaids);4603 var result = matchup.CorrelatedBlocks;4604 Assert.AreEqual(9, result.Count);4605 var refBlocksAttachedToVern = result.SelectMany(vb => vb.ReferenceBlocks)4606 .Select(rb => rb.GetText(false)).ToList();4607 for (int v = 34; v <= 39; v++)4608 {4609 foreach (var rb in refTextMat.GetBlocksForVerse(15, v))4610 {4611 var text = rb.GetText(false);4612 Assert.IsTrue(refBlocksAttachedToVern.Any(t => t.Contains(text)),4613 $"Reference text from verse {v} is missing: {text}");4614 }4615 }4616 }4617 #endregion4618 #region PG-14584619 [Test]4620 public void GetBlocksForVerseMatchedToReferenceText_ErrantRefTextBlockMatchesBlockForPrecedingVerseWithUnexpecteSpeaker_TreatedAsMismatch()4621 {4622 // This is a test for a scenario where a reference text (not English) has a block whose speaker is4623 // expected to speak in a preceding verse but (according to the CV file) NOT for the following verse.4624 // This is actually an error in the reference text but because Glyssen has no control over custom4625 // reference texts, the logic in ReferenceText cannot assume that the reference text will be correct.4626 // Unfortunately, there is a slight discrepancy in the logic when matching up "BlockMatchup" objects4627 // for ISP vs. hooking up everything for export. So we need to ensure that in this scenario the4628 // link to the reference block is not actually considered a "match" so the scripter will have a chance4629 // to look at it and figure out what to do.4630 var vernacularBlocks = new List<Block>();4631 vernacularBlocks.Add(CreateNarratorBlockForVerse(29, "De o ngo Maria duru mataoko itiai ma malaekata ai gea. ", book:"LUK")4632 .AddVerse(30, "Masara o Gabiriele wotemoli munangika wato, "));4633 AddBlockForVerseInProgress(vernacularBlocks, "Gabriel", "“Maria, ngaro ufa nohawana ngonaika hiadono ngona. ")4634 .AddVerse(31, "Abeika ahi demo tonihingahu ngonaika! Abe ani ngofaka o nauru de Una nihiromanga o Yesusu. ")4635 .AddVerse("32-33", "De ani ngofaka gea Una ai Ngofaka. De nanga Baluhu Ma Jou wihidadi nia koano" +4636 "Una ai tofora o Dautu o Isiraele ma nyawa. Ho gea wodadi ti ngini o Yakubu. De ka Unangohi kuahaka!”");4637 vernacularBlocks.Add(CreateNarratorBlockForVerse(34, "De o ngo Maria mopaluhu o malaekatika mato, ", book: "LUK"));4638 AddBlockForVerseInProgress(vernacularBlocks, "Mary, Jesus' mother", "“Masara ngohi ko ma moiuahi tamake o ngofaka gea?” ");4639 var vernBook = new BookScript("LUK", vernacularBlocks, m_vernVersification);4640 var referenceBlocks = new List<Block>();4641 var refBlock = CreateNarratorBlockForVerse(29, "Maria terkejut mendengar perkataan itu, apakah arti salam itu.", book:"LUK")4642 .AddVerse(30, "Kata malaikat itu kepadanya:");4643 referenceBlocks.Add(refBlock);4644 refBlock.SetMatchedReferenceBlock(CreateNarratorBlockForVerse(29, "But she was troubled, wondering what kind of greeting this was.", book:"LUK")4645 .AddVerse(30, "The angel said to her,"));4646 refBlock = AddBlockForVerseInProgress(referenceBlocks, "Gabriel", "«Jangan takut, sebab engkau di hadapan Allah.");4647 refBlock.SetMatchedReferenceBlock("«Don’t be afraid, Mary, for you have found favor with God.");4648 refBlock = CreateBlockForVerse("Gabriel", 31, "Sesungguhnya engkau akan mengandung dan hendaklah engkau menamai Dia Yesus.");4649 referenceBlocks.Add(refBlock);4650 refBlock.SetMatchedReferenceBlock(CreateBlockForVerse("Gabriel", 31, "You will have a son. Name him ‹Jesus.›"));4651 refBlock = CreateBlockForVerse("Gabriel", 32, "Ia akan menjadi Anak Allah Yang Mahatinggi. Dan Tuhan Allah akan takhta Daud, leluhur-Nya.");4652 referenceBlocks.Add(refBlock);4653 refBlock.SetMatchedReferenceBlock(CreateBlockForVerse("Gabriel", 32, "He will be the Son of God and will reign in place of David."));4654 refBlock = CreateBlockForVerse("Gabriel", 33, "La akan menjadi raja atas kaum Kerajaan-Nya tidak akan berkesudahan.")4655 .AddVerse(34, "Bagaimana hal itu mungkin terjadi,» "); // Note: this is the part that is incorrect. This should be Mary.4656 referenceBlocks.Add(refBlock);4657 refBlock.SetMatchedReferenceBlock(CreateBlockForVerse("Gabriel", 33, "He will rule Jacob forever with no end to his Kingdom.» "));4658 refBlock = AddNarratorBlockForVerseInProgress(referenceBlocks, "Kata Maria kepada malaikat itu:", "LUK");4659 refBlock.SetMatchedReferenceBlock(CreateNarratorBlockForVerse(34, "Mary said to the angel,", book:"LUK"));4660 refBlock = AddBlockForVerseInProgress(referenceBlocks, "Mary, Jesus' mother", "«karena aku belum bersuami?» ");4661 refBlock.SetMatchedReferenceBlock("«How can this be, since I am a virgin?»");4662 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks, ReferenceTextType.Custom);4663 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4664 var result = matchup.CorrelatedBlocks;4665 Assert.AreEqual(6, result.Count);4666 Assert.IsTrue(result[0].MatchesReferenceText);4667 Assert.IsTrue(result[1].MatchesReferenceText);4668 Assert.IsTrue(result[2].MatchesReferenceText);4669 Assert.IsFalse(result[3].MatchesReferenceText);4670 Assert.IsTrue(result[4].MatchesReferenceText);4671 Assert.IsTrue(result[5].MatchesReferenceText);4672 Assert.IsTrue(result.All(b => b.ReferenceBlocks.All(ind => ind.MatchesReferenceText)));4673 }4674 #endregion4675 #region PG-14594676 [Test]4677 public void GetBlocksForVerseMatchedToReferenceText_ErrantRefTextBlockWithMisspelledSpeaker_TextIsNotLost()4678 {4679 // This is a test for a scenario where a reference text (not English) has an outdated biblical character4680 // no longer in the control file. Because Glyssen has no control over custom reference texts, this4681 // should not result in lost text.4682 var vernacularBlocks = new List<Block>();4683 vernacularBlocks.Add(CreateNarratorBlockForVerse(8, "Zach stands and declares: ", false, 19, "LUK"));4684 AddBlockForVerseInProgress(vernacularBlocks, "Zacchaeus", "“Lord Jesus, I am done with my life of crime!”");4685 AddNarratorBlockForVerseInProgress(vernacularBlocks, "he said.");4686 var vernBook = new BookScript("LUK", vernacularBlocks, m_vernVersification);4687 var referenceBlocks = new List<Block>();4688 var refBlock = CreateNarratorBlockForVerse(8,4689 "Tetapi Zakheus berdiri dan berkata kepada Tuhan:", true, 19, "LUK");4690 referenceBlocks.Add(refBlock);4691 refBlock.SetMatchedReferenceBlock(CreateNarratorBlockForVerse(29,4692 "Zacchaeus stood and said to the Lord,", true, 19, "LUK"));4693 refBlock = AddBlockForVerseInProgress(referenceBlocks, "Zachary",4694 "“Tuhan, setengah dari seseorang akan empat kali lipat.”");4695 refBlock.SetMatchedReferenceBlock("“Lord, I give half to the poor. I will repay stolen stuff fourfold.”");4696 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks, ReferenceTextType.Custom);4697 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0);4698 var result = matchup.CorrelatedBlocks;4699 Assert.AreEqual(3, result.Count);4700 Assert.IsTrue(result[0].MatchesReferenceText);4701 Assert.IsTrue(!result[1].MatchesReferenceText || !result[2].MatchesReferenceText);4702 Assert.AreEqual(referenceBlocks.Last().GetText(true), result.Skip(1).SelectMany(s => s.ReferenceBlocks).Single().GetText(true));4703 Assert.IsTrue(result.All(b => b.ReferenceBlocks.All(ind => ind.MatchesReferenceText)));4704 }4705 [TestCase()]4706 [TestCase("—jai.")]4707 [TestCase("—jai fariseowi.", "—jai.", "—jaibeje.")]4708 [TestCase("—jai fariseowi.", "—jaibeje.")]4709 public void GetBlocksForVerseMatchedToReferenceText_KnownTrailingHeSaidAfterMiddleMismatchedBlock_TextOfRefTextIsNotLost(params string[] knownHeSaids)4710 {4711 // This test was written for a scenario where a reference text (not English) has an4712 // outdated biblical character ID (different from the control file). This was actually4713 // an error in the reference text but because Glyssen has no control over custom4714 // reference texts, this kind of error should not result in lost text. For this4715 // scenario, two of the four test cases failed.4716 // However, also note that the fix for this also fixed several other real-life4717 // scenarios that were not caused by problems in the reference text.4718 var vernacularBlocks = new List<Block>();4719 vernacularBlocks.Add(CreateNarratorBlockForVerse(5, "Itsamatacabi, Jesús pija-apóstolewi jumaitsi Jesús-jawabelia:", false, 17, "LUK"));4720 AddBlockForVerseInProgress(vernacularBlocks, "disciples", "—¡Patajatuxanenë, paneyawenonare patajamatabëcuenewitsabinexa pata-itaxutuajamatejemajawa Diosojawabelia! ");4721 AddNarratorBlockForVerseInProgress(vernacularBlocks, "—jai.");4722 var vernBook = new BookScript("LUK", vernacularBlocks, m_vernVersification);4723 var referenceBlocks = new List<Block>();4724 var refBlock = CreateNarratorBlockForVerse(5,4725 "Los apóstoles le pidieron al Señor:", true, 17, "LUK");4726 referenceBlocks.Add(refBlock);4727 refBlock.SetMatchedReferenceBlock(CreateNarratorBlockForVerse(5,4728 "The apostles said to the Lord,", true, 17, "LUK"));4729 refBlock = AddBlockForVerseInProgress(referenceBlocks, "apostles",4730 "“Aumente nuestro fe.”");4731 refBlock.SetMatchedReferenceBlock("“Increase our faith.”");4732 var refText = TestReferenceText.CreateTestReferenceText(vernBook.BookId, referenceBlocks);4733 var matchup = refText.GetBlocksForVerseMatchedToReferenceText(vernBook, 0, knownHeSaids);4734 var result = matchup.CorrelatedBlocks;4735 Assert.AreEqual(3, result.Count);4736 var attachedRefTexts = result.SelectMany(r => r.ReferenceBlocks).Select(b => b.GetText(false)).ToList();4737 Assert.That(referenceBlocks.Select(b => b.GetText(false)).All(t => attachedRefTexts.Contains(t)));4738 }4739 #endregion4740 #region private helper methods4741 private Block NewChapterBlock(string bookId, int chapterNum, string text = null)4742 {4743 var block = new Block("c", chapterNum)4744 {4745 BookCode = bookId,4746 IsParagraphStart = true,4747 CharacterId = CharacterVerseData.GetStandardCharacterId(bookId, CharacterVerseData.StandardCharacter.BookOrChapter)4748 };4749 block.BlockElements.Add(new ScriptText(text ?? chapterNum.ToString()));4750 return block;4751 }4752 internal static Block CreateBlockForVerse(string characterId, int initialStartVerseNumber, string text, bool paraStart = false,4753 int chapter = 1, string styleTag = "p", int initialEndVerseNumber = 0)4754 {4755 var block = new Block(styleTag, chapter, initialStartVerseNumber, initialEndVerseNumber)4756 {4757 IsParagraphStart = paraStart,4758 CharacterId = characterId,4759 };4760 if (initialEndVerseNumber > 0)4761 block.AddVerse(Format("{0}-{1}", initialStartVerseNumber, initialEndVerseNumber), text);4762 else4763 block.AddVerse(initialStartVerseNumber, text);4764 return block;4765 }4766 internal static Block AddBlockForVerseInProgress(IList<Block> list, string characterId, string text, string styleTag = "")4767 {4768 var lastBlock = list.Last();4769 var initialStartVerse = lastBlock.InitialStartVerseNumber;4770 var initialEndVerse = lastBlock.InitialEndVerseNumber;4771 var lastVerseElement = lastBlock.BlockElements.OfType<Verse>().LastOrDefault();4772 if (lastVerseElement != null)4773 {4774 initialStartVerse = BCVRef.VerseToIntStart(lastVerseElement.Number);4775 initialEndVerse = BCVRef.VerseToIntEnd(lastVerseElement.Number);4776 }4777 if (IsNullOrEmpty(styleTag))4778 styleTag = lastBlock.StyleTag;4779 var block = new Block(styleTag, lastBlock.ChapterNumber, initialStartVerse, initialEndVerse)4780 {4781 CharacterId = characterId,4782 IsParagraphStart = styleTag != lastBlock.StyleTag,4783 };4784 block.BlockElements.Add(new ScriptText(text));4785 list.Add(block);4786 return block;4787 }4788 internal static Block AddNarratorBlockForVerseInProgress(IList<Block> list, string text, string book = "MAT")4789 {4790 return AddBlockForVerseInProgress(list, CharacterVerseData.GetStandardCharacterId(book, CharacterVerseData.StandardCharacter.Narrator), text);4791 }4792 internal static Block CreateNarratorBlockForVerse(int verseNumber, string text, bool paraStart = false, int chapter = 1,4793 string book = "MAT", string styleTag = "p", int initialEndVerseNumber = 0)4794 {4795 return CreateBlockForVerse(CharacterVerseData.GetStandardCharacterId(book, CharacterVerseData.StandardCharacter.Narrator),4796 verseNumber, text, paraStart, chapter, styleTag, initialEndVerseNumber);4797 }4798 /// <summary>4799 /// Gets a block that has both LuUK 23:17 and the start of v. 18, and also (as an output param) the4800 /// block containing the end of v. 18.4801 /// In v. 112 of the DG, these two verses were split out into separate blocks. Not sure4802 /// if there are other places where this could reasonably occur, but as least for now, I'm4803 /// going to leave the tests cases (and the production code) for this. So this method modifies4804 /// the built-in reference text to be the way it was in previous versions of the DG.4805 /// </summary>4806 /// <returns></returns>4807 private Block GetLuke23v17And18Block(ReferenceText englishReferenceText, out Block lastBlockForV18, out Action cleanup)4808 {4809 const string kLukBookId = "LUK";4810 var luk = englishReferenceText.Books.Single(b => b.BookId == kLukBookId);4811 var iLuk23v17 = luk.GetIndexOfFirstBlockForVerse(23, 17);4812 var v17And18Block = luk[iLuk23v17];4813 var v18RefTextBlocks = luk.GetBlocksForVerse(23, 18).ToList();4814 lastBlockForV18 = v18RefTextBlocks.Last();4815 Assert.AreEqual(2, v18RefTextBlocks.Count, "Test setup conditions not met");4816 if (v17And18Block != v18RefTextBlocks.First())4817 {4818 // This is a semi-dangerous hack. Since we can't get the lock, this isn't thread-safe.4819 cleanup = () =>4820 {4821 var modifiedBooks = (HashSet<string>)ReflectionHelper.GetField(englishReferenceText, "m_modifiedBooks");...

Full Screen

Full Screen

UsersPage.cs

Source:UsersPage.cs Github

copy

Full Screen

...30 return rowCount;31 }32 public class UserRow : KendoGridRow<_>33 {34 //TODO: Add toggle dropdown for Action column35 public Text<_> FirstName { get; private set; }36 public Text<_> LastName { get; private set; }37 public Text<_> EmailAddress { get; private set; }38 [Term("2FA")]39 public Text<_> TwoFA { get; private set; }40 public Text<_> Roles { get; private set; }41 public Text<_> Groups { get; private set; }42 public Text<_> Status { get; private set; }43 }44 private readonly ILogger _logger;45 }46}...

Full Screen

Full Screen

SampleTests.cs

Source:SampleTests.cs Github

copy

Full Screen

...15 Go.To<HomePage>().16 Header.Should.Equal("Atata Sample App");17 }18 /// <summary>19 /// Use such approach with <see cref="UITestFixture.Execute(System.Action)"/> method when you need to add exception/error information to the log.20 /// It is needed if you log to file or other external source.21 /// </summary>22 [TestMethod]23 public void MSTestWithExceptionLogging()24 {25 Execute(() =>26 {27 Go.To<HomePage>().28 Header.Should.Equal("Atata Sample App");29 ////Header.Should.Equal("Unknown Title");30 });31 }32 }33}...

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1using Atata;2using NUnit.Framework;3{4 {5 public void Add()6 {7 Go.To<Add>()8 .Set(x => x.Number1, 5)9 .Set(x => x.Number2, 10)10 .Calculate.ClickAndGo<AddResult>()11 .Result.Should.Equal(15);12 }13 }14}15using Atata;16using NUnit.Framework;17{18 {19 public void Add()20 {21 Go.To<Add>()22 .Number1.Set(5)23 .Number2.Set(10)24 .Calculate.ClickAndGo<AddResult>()25 .Result.Should.Equal(15);26 }27 }28}29using Atata;30using NUnit.Framework;31{32 {33 public void Add()34 {35 Go.To<Add>()36 .Number1.Set(5)37 .Number2.Set(10)38 .Calculate.ClickAndGo<AddResult>()39 .Result.Should.Equal(15);40 }41 }42}43using Atata;44using NUnit.Framework;45{46 {47 public void Add()48 {49 Go.To<Add>()50 .Number1.Set(5)51 .Number2.Set(10)52 .Calculate.ClickAndGo<AddResult>()53 .Result.Should.Equal(15);54 }55 }56}57using Atata;58using NUnit.Framework;59{60 {61 public void Add()62 {63 Go.To<Add>()64 .Number1.Set(5)65 .Number2.Set(10)66 .Calculate.ClickAndGo<AddResult>()67 .Result.Should.Equal(15);68 }69 }70}

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1public void TestMethod1()2{3 Go.To<Add>().AddNumbers(5, 10);4}5public void TestMethod1()6{7 Go.To<Add>().AddNumbers(5, 10);8}9public void TestMethod1()10{11 Go.To<Add>().AddNumbers(5, 10);12}13public void TestMethod1()14{15 Go.To<Add>().AddNumbers(5, 10);16}17public void TestMethod1()18{19 Go.To<Add>().AddNumbers(5, 10);20}21public void TestMethod1()22{23 Go.To<Add>().AddNumbers(5, 10);24}25public void TestMethod1()26{27 Go.To<Add>().AddNumbers(5, 10);28}29public void TestMethod1()30{31 Go.To<Add>().AddNumbers(5, 10);32}33public void TestMethod1()34{35 Go.To<Add>().AddNumbers(5, 10);36}37public void TestMethod1()38{39 Go.To<Add>().AddNumbers(5, 10);40}41public void TestMethod1()42{43 Go.To<Add>().AddNumbers(5, 10);44}

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1public void TestMethod1()2{3 Go.To<Add>()4 .Number1.Set("5")5 .Number2.Set("10")6 .AddButton.ClickAndGo();7 Assert.AreEqual("15", Go.To<Add>().Result.Get());8}9public void TestMethod1()10{11 Go.To<Add>()12 .Number1.Set("5")13 .Number2.Set("10")14 .AddButton.ClickAndGo();15 Assert.AreEqual("15", Go.To<Add>().Result.Get());16}17public void TestMethod1()18{19 Go.To<Add>()20 .Number1.Set("5")21 .Number2.Set("10")22 .AddButton.ClickAndGo();23 Assert.AreEqual("15", Go.To<Add>().Result.Get());24}25public void TestMethod1()26{27 Go.To<Add>()28 .Number1.Set("5")29 .Number2.Set("10")30 .AddButton.ClickAndGo();31 Assert.AreEqual("15", Go.To<Add>().Result.Get());32}33public void TestMethod1()34{35 Go.To<Add>()36 .Number1.Set("5")37 .Number2.Set("10")38 .AddButton.ClickAndGo();39 Assert.AreEqual("15", Go.To<Add>().Result.Get());40}41public void TestMethod1()42{43 Go.To<Add>()44 .Number1.Set("5")45 .Number2.Set("10")46 .AddButton.ClickAndGo();47 Assert.AreEqual("15", Go.To<Add>().Result.Get());48}49public void TestMethod1()50{51 Go.To<Add>()52 .Number1.Set("5")53 .Number2.Set("10")54 .AddButton.ClickAndGo();55 Assert.AreEqual("15", Go.To

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1public void TestMethod1()2{3 Go.To<Add>()4 .Number1.Set("1")5 .Number2.Set("2")6 .Add.Click();7}8public void TestMethod1()9{10 Go.To<Add>()11 .Number1.Set("1")12 .Number2.Set("2")13 .Add.Click();14}15public void TestMethod1()16{17 Go.To<Add>()18 .Number1.Set("1")19 .Number2.Set("2")20 .Add.Click();21}22public void TestMethod1()23{24 Go.To<Add>()25 .Number1.Set("1")26 .Number2.Set("2")27 .Add.Click();28}29public void TestMethod1()30{31 Go.To<Add>()32 .Number1.Set("1")33 .Number2.Set("2")34 .Add.Click();35}36public void TestMethod1()37{38 Go.To<Add>()39 .Number1.Set("1")40 .Number2.Set("2")41 .Add.Click();42}43public void TestMethod1()44{45 Go.To<Add>()46 .Number1.Set("1")47 .Number2.Set("2")48 .Add.Click();49}50public void TestMethod1()51{52 Go.To<Add>()53 .Number1.Set("1")54 .Number2.Set("2")55 .Add.Click();56}57public void TestMethod1()58{59 Go.To<Add>()60 .Number1.Set("1")61 .Number2.Set("2")

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1using Atata;2using NUnit.Framework;3{4 {5 public void TestMethod()6 {7 Result.Should.Equal(5);8 }9 }10}

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1using Atata;2using Atata.Tests;3using NUnit.Framework;4{5{6public void SetUp()7{8Go.To<Add>();9}10}11}12using Atata;13using Atata.Tests;14using NUnit.Framework;15{16{17[TestCase(2, 2, 4)]18[TestCase(3, 3, 6)]19public void Test1(int num1, int num2, int expected)20{21Go.To<Add>()22.Number1.Set(num1)23.Number2.Set(num2)24.Add.ClickAndGo<Sum>()25.Result.Should.Equal(expected);26}27}28}29using Atata;30using Atata.Tests;31using NUnit.Framework;32{33{34[TestCase(2, 2, 4)]35[TestCase(3, 3, 6)]36public void Test1(int num1, int num2, int expected)37{38Go.To<Add>()39.Number1.Set(num1)40.Number2.Set(num2)41.Add.ClickAndGo<Sum>()42.Result.Should.Equal(expected);43}44}45}46using Atata;47using Atata.Tests;48using NUnit.Framework;49{50{51[TestCase(2, 2, 4)]52[TestCase(3, 3, 6)]53public void Test1(int num1, int num2, int expected)54{55Go.To<Add>()56.Number1.Set(num1)57.Number2.Set(num2)58.Add.ClickAndGo<Sum>()59.Result.Should.Equal(expected);60}61}62}63using Atata;64using Atata.Tests;65using NUnit.Framework;66{67{68[TestCase(2, 2,

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1public void TestMethod1()2{3 Go.To<Add>();4 Add add = new Add();5 add.AddNumbers(10, 20);6 add.Result.Should.Equal(30);7}8public void TestMethod1()9{10 Go.To<Add>();11 Add add = new Add();12 add.AddNumbers(10, 20);13 add.Result.Should.Equal(30);14}15public void TestMethod1()16{17 Go.To<LoginPage>();18 LoginPage loginPage = new LoginPage();19 loginPage.Login("username", "password");20 Go.To<HomePage>();21 HomePage homePage = new HomePage();22 homePage.Logout();23}24public void TestMethod1()25{26 Go.To<LoginPage>();27 LoginPage loginPage = new LoginPage();28 loginPage.Login("username", "password");29 Go.To<HomePage>();30 HomePage homePage = new HomePage();31 homePage.Logout();32}33public void TestMethod1()34{35 Go.To<LoginPage>();36 LoginPage loginPage = new LoginPage();37 loginPage.Login("username", "password");38 Go.To<HomePage>();

Full Screen

Full Screen

Action

Using AI Code Generation

copy

Full Screen

1using System;2{3 public static void Main()4 {5 Console.WriteLine("Enter the first number");6 int a = Convert.ToInt32(Console.ReadLine());7 Console.WriteLine("Enter the second number");8 int b = Convert.ToInt32(Console.ReadLine());9 int c = Atata.Tests.Add.Action(a,b);10 Console.WriteLine("The sum of two numbers is {0}", c);11 }12}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful