public void FullyRegenerateGroups_FewDeletionsAndManyGroups_GroupsRegenerated()
        {
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = true;
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(190, 4, 2);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = false;
            var adjuster           = new CharacterGroupsAdjuster(m_testProject);
            var charactersNotInUse = adjuster.CharactersNoLongerInUse.ToList();

            Assert.IsTrue(charactersNotInUse.Count > 0);
            Assert.IsTrue(charactersNotInUse.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(charactersNotInUse.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(charactersNotInUse.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            var originalCountOfGroups = m_testProject.CharacterGroupList.CharacterGroups.Count;
            var groupsToRemove        = adjuster.CharacterGroupsToRemove.ToList();

            Assert.IsTrue(groupsToRemove.Any());

            adjuster.FullyRegenerateGroups();
            Assert.IsFalse(adjuster.GroupsAreNotInSynchWithData);
            Assert.IsFalse(adjuster.CharactersNoLongerInUse.Any());
            Assert.IsFalse(adjuster.CharactersNotCoveredByAnyGroup.Any());
            Assert.IsFalse(adjuster.CharacterGroupsToRemove.Any());
            Assert.AreEqual(originalCountOfGroups - 2, m_testProject.CharacterGroupList.CharacterGroups.Count);
            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => !g.CharacterIds.Any() || g.CharacterIds.Any(c => charactersNotInUse.Contains(c))));
            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => groupsToRemove.Contains(g)));
            Assert.IsFalse(adjuster.NewBooksHaveBeenIncluded);
            Assert.IsFalse(adjuster.BooksHaveBeenExcluded);
            Assert.IsFalse(adjuster.FullRegenerateRecommended);
        }
        public void MakeMinimalAdjustments_FewAdditions_NewGroupAddedWithNewCharacters()
        {
            SetVoiceActors(9, 2, 1);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = true;
            m_testProject.ClearCharacterStatistics();             // This simulates behavior in UI when the project is saved after displaying ScriptureRangeSelectionDlg
            var adjuster = new CharacterGroupsAdjuster(m_testProject);

            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            var countOfCharactersNotCovered = adjuster.CharactersNotCoveredByAnyGroup.Count();

            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            var originalCountOfGroups = m_testProject.CharacterGroupList.CharacterGroups.Count;

            adjuster.MakeMinimalAdjustments();
            Assert.IsFalse(adjuster.GroupsAreNotInSynchWithData);
            Assert.AreEqual(0, adjuster.CharactersNotCoveredByAnyGroup.Count());
            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            Assert.AreEqual(originalCountOfGroups + 1, m_testProject.CharacterGroupList.CharacterGroups.Count);
            var newGroup = m_testProject.CharacterGroupList.GroupContainingCharacterId(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator));

            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => g.GroupId == newGroup.GroupId && g != newGroup));
            Assert.IsTrue(newGroup.CharacterIds.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(newGroup.CharacterIds.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            Assert.AreEqual(countOfCharactersNotCovered, newGroup.CharacterIds.Count);
        }
        public void MakeMinimalAdjustments_FewAdditions_NewGroupAddedWithNewCharacters()
        {
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(9, 2, 1);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = true;
            var adjuster = new CharacterGroupsAdjuster(m_testProject);

            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            var countOfCharactersNotCovered = adjuster.CharactersNotCoveredByAnyGroup.Count();

            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            var originalCountOfGroups = m_testProject.CharacterGroupList.CharacterGroups.Count;

            adjuster.MakeMinimalAdjustments();
            Assert.IsFalse(adjuster.GroupsAreNotInSynchWithData);
            Assert.AreEqual(0, adjuster.CharactersNotCoveredByAnyGroup.Count());
            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            Assert.AreEqual(originalCountOfGroups + 1, m_testProject.CharacterGroupList.CharacterGroups.Count);
            var newGroup = m_testProject.CharacterGroupList.GroupContainingCharacterId(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator));

            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => g.GroupNumber == newGroup.GroupNumber && g != newGroup));
            Assert.IsTrue(newGroup.CharacterIds.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(newGroup.CharacterIds.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            Assert.AreEqual(countOfCharactersNotCovered, newGroup.CharacterIds.Count);
        }
        public void FullyRegenerateGroups_FewAdditions_GroupsRegenerated()
        {
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(9, 2, 1);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = true;
            var adjuster        = new CharacterGroupsAdjuster(m_testProject);
            var addedCharacters = adjuster.CharactersNotCoveredByAnyGroup.ToList();

            Assert.IsTrue(addedCharacters.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(addedCharacters.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(addedCharacters.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            var originalCountOfGroups = m_testProject.CharacterGroupList.CharacterGroups.Count;

            adjuster.FullyRegenerateGroups();
            Assert.IsFalse(adjuster.GroupsAreNotInSynchWithData);
            Assert.AreEqual(0, adjuster.CharactersNotCoveredByAnyGroup.Count());
            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            Assert.AreEqual(originalCountOfGroups, m_testProject.CharacterGroupList.CharacterGroups.Count);
            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => !g.CharacterIds.Any()));
            Assert.IsTrue(addedCharacters.All(c => m_testProject.CharacterGroupList.GroupContainingCharacterId(c) != null));
            Assert.IsFalse(adjuster.NewBooksHaveBeenIncluded);
            Assert.IsFalse(adjuster.BooksHaveBeenExcluded);
            Assert.IsFalse(adjuster.FullRegenerateRecommended);
        }
        public void DistributeBooksAmongNarratorGroups_TwoAuthorsOfSixBooksAmongFiveNarrators_AuthorWithLongestBooksSplit()
        {
            var keyStrokesByBook = new Dictionary <string, int>();

            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("GEN", CharacterVerseData.StandardCharacter.Narrator)] = 50000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("EXO", CharacterVerseData.StandardCharacter.Narrator)] = 28000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("LEV", CharacterVerseData.StandardCharacter.Narrator)] = 28000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("DEU", CharacterVerseData.StandardCharacter.Narrator)] = 28000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JHN", CharacterVerseData.StandardCharacter.Narrator)] = 20000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("REV", CharacterVerseData.StandardCharacter.Narrator)] = 22000;

            var narratorGroups = GetNarratorCharacterGroups(5);

            CharacterGroupGenerator.TrialGroupConfiguration.DistributeBooksAmongNarratorGroups(narratorGroups, 2,
                                                                                               keyStrokesByBook.Keys.Select(CharacterVerseData.GetBookCodeFromStandardCharacterId), keyStrokesByBook);
            var narratorGroupForJohn = GetNarratorGroupForBook(narratorGroups, "JHN");

            Assert.AreEqual(narratorGroupForJohn, GetNarratorGroupForBook(narratorGroups, "REV"));
            var listOfBooksFoundSoFar = new HashSet <string>();

            foreach (var group in narratorGroups)
            {
                var booksAssignedToNarrator = group.CharacterIds.Select(CharacterVerseData.GetBookCodeFromStandardCharacterId).ToList();
                if (group != narratorGroupForJohn)
                {
                    Assert.AreEqual(1, booksAssignedToNarrator.Count);
                }
                Assert.IsFalse(listOfBooksFoundSoFar.Overlaps(booksAssignedToNarrator));
                listOfBooksFoundSoFar.AddRange(booksAssignedToNarrator);
            }
        }
        public void MakeMinimalAdjustments_FewDeletionsAndManyGroups_CharactersRemovedFromExistingCharacterGroupsAndEmptyGroupsRemoved()
        {
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = true;
            m_testProject.ClearCharacterStatistics();             // This simulates behavior in UI when the project is saved after displaying ScriptureRangeSelectionDlg
            SetVoiceActors(100, 7, 2);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = false;
            m_testProject.ClearCharacterStatistics();             // This simulates behavior in UI when the project is saved after displaying ScriptureRangeSelectionDlg
            var adjuster           = new CharacterGroupsAdjuster(m_testProject);
            var charactersNotInUse = adjuster.CharactersNoLongerInUse.ToList();

            Assert.IsTrue(charactersNotInUse.Count > 0);
            Assert.IsTrue(charactersNotInUse.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(charactersNotInUse.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(charactersNotInUse.Contains(CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.BookOrChapter)));
            var originalCountOfGroups = m_testProject.CharacterGroupList.CharacterGroups.Count;
            var groupsToRemove        = adjuster.CharacterGroupsToRemove.ToList();

            Assert.IsTrue(groupsToRemove.Any());

            adjuster.MakeMinimalAdjustments();
            Assert.IsFalse(adjuster.GroupsAreNotInSynchWithData);
            Assert.IsFalse(adjuster.CharactersNoLongerInUse.Any());
            Assert.IsFalse(adjuster.CharactersNotCoveredByAnyGroup.Any());
            Assert.IsFalse(adjuster.CharacterGroupsToRemove.Any());
            Assert.AreEqual(originalCountOfGroups - groupsToRemove.Count, m_testProject.CharacterGroupList.CharacterGroups.Count);
            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => !g.CharacterIds.Any() || g.CharacterIds.Any(c => charactersNotInUse.Contains(c))));
            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => groupsToRemove.Contains(g)));
        }
Example #7
0
        /// <summary>
        /// Gets all known (potential and/or expected) characters for the given reference range. If any of
        /// them are Hypothetical, those characters will only be included if the reference text contains a
        /// block actually assigned to that hypothetical character. Otherwise, the hypothetical character
        /// will be treated as a narrator "quotation."
        /// </summary>
        public HashSet <CharacterSpeakingMode> GetCharacters(int bookId, int chapter, IReadOnlyCollection <IVerse> verses,
                                                             ScrVers versification = null, bool includeAlternatesAndRareQuotes = false, bool includeNarratorOverrides = false)
        {
            Debug.Assert(!includeNarratorOverrides, "Can't think of any valid reason the quote parser should ever want to consider" +
                         "narrator overrides. These should be applied only after user has done disambiguation.");
            var result = m_cvInfo.GetCharacters(bookId, chapter, verses, versification,
                                                includeAlternatesAndRareQuotes, includeNarratorOverrides);
            var hypotheticalsToReplace = result.Where(cv =>
            {
                if (cv.QuoteType == QuoteType.Hypothetical)
                {
                    var refTextBook = m_referenceText.GetBook(bookId);
                    if (refTextBook != null)
                    {
                        return(!refTextBook.GetBlocksForVerse(chapter,
                                                              verses.First().StartVerse, verses.Last().EndVerse).Any(b => b.CharacterId == cv.Character));
                    }
                    // REVIEW: Should we replace hypotheticals if there is no reference text for this book?
                }
                return(false);
            }).Select(c => c.Character).ToList();

            if (hypotheticalsToReplace.Any())
            {
                result.Add(new CharacterSpeakingMode(CharacterVerseData.GetStandardCharacterId(BCVRef.NumberToBookCode(bookId), CharacterVerseData.StandardCharacter.Narrator),
                                                     String.Empty, String.Empty, false, QuoteType.Quotation));
                result.RemoveAll(e => e.QuoteType == QuoteType.Hypothetical && hypotheticalsToReplace.Contains(e.Character));
            }

            return(result);
        }
Example #8
0
        public void CalculateMinimumProximity_NonStrictAdherenceToNarratorPrefs_AllStandardCharactersAndBookAuthorResultsInMaxProximity()
        {
            var project = TestProject.CreateTestProject(TestProject.TestBook.JOS);             // Using Joshua because the test data for Joshua has into material

            project.UseDefaultForUnresolvedMultipleChoiceCharacters();

            project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.SingleNarrator;
            // By making theses all different, we force the CharacterGroupGenerator (which we aren't calling here) to put each
            // type of standard character in a different group, but with "not strict" proximity, we still consider it legit to
            // manually put them in the same group.
            project.DramatizationPreferences.BookTitleAndChapterDramatization = ExtraBiblicalMaterialSpeakerOption.ActorOfEitherGender;
            project.DramatizationPreferences.BookIntroductionsDramatization   = ExtraBiblicalMaterialSpeakerOption.FemaleActor;
            project.DramatizationPreferences.SectionHeadDramatization         = ExtraBiblicalMaterialSpeakerOption.MaleActor;

            var proximity = new Proximity(project, false);

            var characterIds = new HashSet <string>
            {
                CharacterVerseData.GetStandardCharacterId("JOS", CharacterVerseData.StandardCharacter.Narrator),
                CharacterVerseData.GetStandardCharacterId("JOS", CharacterVerseData.StandardCharacter.ExtraBiblical),
                CharacterVerseData.GetStandardCharacterId("JOS", CharacterVerseData.StandardCharacter.Intro),
                CharacterVerseData.GetStandardCharacterId("JOS", CharacterVerseData.StandardCharacter.BookOrChapter),
            };

            MinimumProximity minProximity = proximity.CalculateMinimumProximity(characterIds);

            Assert.AreEqual(Int32.MaxValue, minProximity.NumberOfBlocks);
        }
        /// <summary>Populates bookData with the standard characters that should be allowed to be grouped together without causing proximity problems</summary>
        private void GetStandardCharactersToTreatAsOne(BookScript book, ProjectDramatizationPreferences dramatizationPreferences,
                                                       Dictionary <ExtraBiblicalMaterialSpeakerOption, HashSet <string> > bookData)
        {
            if (m_strictlyAdhereToNarratorPreferences)
            {
                AddOrNew(bookData, dramatizationPreferences.BookTitleAndChapterDramatization, CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.BookOrChapter));
                AddOrNew(bookData, dramatizationPreferences.SectionHeadDramatization, CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.ExtraBiblical));
                AddOrNew(bookData, dramatizationPreferences.BookIntroductionsDramatization, CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.Intro));
                bookData.Remove(ExtraBiblicalMaterialSpeakerOption.Omitted);

                // add the narrator to its group if there are others there already
                if (bookData.ContainsKey(ExtraBiblicalMaterialSpeakerOption.Narrator))
                {
                    bookData[ExtraBiblicalMaterialSpeakerOption.Narrator].Add(book.NarratorCharacterId);
                }
            }
            else
            {
                AddOrNew(bookData, ExtraBiblicalMaterialSpeakerOption.Narrator, book.NarratorCharacterId);
                if (dramatizationPreferences.BookTitleAndChapterDramatization != ExtraBiblicalMaterialSpeakerOption.Omitted)
                {
                    bookData[ExtraBiblicalMaterialSpeakerOption.Narrator].Add(CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.BookOrChapter));
                }
                if (dramatizationPreferences.SectionHeadDramatization != ExtraBiblicalMaterialSpeakerOption.Omitted)
                {
                    bookData[ExtraBiblicalMaterialSpeakerOption.Narrator].Add(CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.ExtraBiblical));
                }
                if (dramatizationPreferences.BookIntroductionsDramatization != ExtraBiblicalMaterialSpeakerOption.Omitted)
                {
                    bookData[ExtraBiblicalMaterialSpeakerOption.Narrator].Add(CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.Intro));
                }
            }
        }
Example #10
0
 private void InsertHeSaidText(IReferenceLanguageInfo referenceLanguageInfo, int i, Action <int, int, string> handleHeSaidInserted, int level = 0)
 {
     if (CorrelatedBlocks[i].CharacterIs(m_vernacularBook.BookId, CharacterVerseData.StandardCharacter.Narrator) ||
         CorrelatedBlocks[i].CharacterId == CharacterVerseData.kUnknownCharacter)
     {
         if (CorrelatedBlocks[i].GetReferenceTextAtDepth(level) == "")
         {
             if (CorrelatedBlocks[i].CharacterId == CharacterVerseData.kUnknownCharacter)
             {
                 CorrelatedBlocks[i].CharacterId = CharacterVerseData.GetStandardCharacterId(m_vernacularBook.BookId, CharacterVerseData.StandardCharacter.Narrator);
             }
             var text = referenceLanguageInfo.HeSaidText;
             if (i < CorrelatedBlocks.Count - 1 && !CorrelatedBlocks[i + 1].IsParagraphStart)
             {
                 text += referenceLanguageInfo.WordSeparator;
             }
             SetReferenceText(i, text, level);
             handleHeSaidInserted(i, level, text);
         }
         if (referenceLanguageInfo.HasSecondaryReferenceText)
         {
             InsertHeSaidText(referenceLanguageInfo.BackingReferenceLanguage, i, handleHeSaidInserted, level + 1);
         }
     }
 }
Example #11
0
        private List <Tuple <int, string, List <object> > > GetExportData()
        {
            if (m_data == null)
            {
                int blockNumber = 1;
                var data        = new List <Tuple <int, string, List <object> > >();

                foreach (var book in Project.IncludedBooks)
                {
                    string singleVoiceNarratorOverride = null;
                    if (book.SingleVoice)
                    {
                        singleVoiceNarratorOverride = CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.Narrator);
                    }
                    foreach (var block in book.GetScriptBlocks(true))
                    {
                        if (IncludeVoiceActors)
                        {
                            VoiceActor.VoiceActor voiceActor = Project.GetVoiceActorForCharacter(singleVoiceNarratorOverride ?? block.CharacterIdInScript);
                            data.Add(GetExportDataForBlock(block, blockNumber++, book.BookId, voiceActor, singleVoiceNarratorOverride, IncludeVoiceActors));
                        }
                        else
                        {
                            data.Add(GetExportDataForBlock(block, blockNumber++, book.BookId, null, singleVoiceNarratorOverride, IncludeVoiceActors));
                        }
                    }
                }
                m_data = data;
            }
            return(m_data);
        }
Example #12
0
        public void Constructor_BooksWithSameAuthors_StatsCombinedForBooksWithSameAuthors()
        {
            var keyStrokesByBook = new Dictionary <string, int>();

            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("GEN", CharacterVerseData.StandardCharacter.Narrator)] = 50000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("ISA", CharacterVerseData.StandardCharacter.Narrator)] = 66000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JER", CharacterVerseData.StandardCharacter.Narrator)] = 52000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("EZK", CharacterVerseData.StandardCharacter.Narrator)] = 48000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("LUK", CharacterVerseData.StandardCharacter.Narrator)] = 24000;             // 52000 combined
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("ACT", CharacterVerseData.StandardCharacter.Narrator)] = 28000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JHN", CharacterVerseData.StandardCharacter.Narrator)] = 20000;             // 42000 combined
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("REV", CharacterVerseData.StandardCharacter.Narrator)] = 22000;
            var includedBooks = new List <string> {
                "GEN", "ISA", "JER", "EZK", "LUK", "ACT", "JHN", "REV"
            };

            Assert.AreEqual(50000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("GEN"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(66000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("ISA"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(52000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("JER"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(48000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("EZK"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(52000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("LUK"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(52000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("ACT"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(42000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("JHN"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(42000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("REV"), includedBooks, keyStrokesByBook).KeyStrokeCount);
        }
Example #13
0
        public void CalculateMinimumProximity_TreatStandardNonScriptureCharactersAsDistinct_ExtraBiblicalResultsInZeroProximityWithChapterNumber()
        {
            var project = TestProject.CreateTestProject(TestProject.TestBook.MRK);

            project.UseDefaultForUnresolvedMultipleChoiceCharacters();

            project.DramatizationPreferences.BookTitleAndChapterDramatization = ExtraBiblicalMaterialSpeakerOption.MaleActor;
            project.DramatizationPreferences.SectionHeadDramatization         = ExtraBiblicalMaterialSpeakerOption.ActorOfEitherGender;
            project.DramatizationPreferences.BookIntroductionsDramatization   = ExtraBiblicalMaterialSpeakerOption.FemaleActor;

            var proximity = new Proximity(project.IncludedBooks, project.DramatizationPreferences);

            var characterIds = new HashSet <string>
            {
                CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.BookOrChapter),
                CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.ExtraBiblical),
                CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Intro)
            };


            MinimumProximity minProximity = proximity.CalculateMinimumProximity(characterIds);

            Assert.AreEqual(0, minProximity.NumberOfBlocks);
            Assert.AreEqual(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.BookOrChapter), minProximity.FirstCharacterId);
            Assert.AreEqual(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.ExtraBiblical), minProximity.SecondCharacterId);
            Assert.AreEqual("MRK 1:0", minProximity.FirstReference);
            Assert.AreEqual("MRK 1:0", minProximity.SecondReference);
        }
Example #14
0
        public void CalculateMinimumProximity_NarrationByAuthor_NonStrictAdherenceToNarratorPrefs_AllStandardCharactersAndBookAuthorResultsInMaxProximity()
        {
            var project = TestProject.CreateTestProject(TestProject.TestBook.GAL);

            project.UseDefaultForUnresolvedMultipleChoiceCharacters();
            var idPaul = BiblicalAuthors.GetAuthorOfBook("GAL").Name;

            foreach (var block in project.IncludedBooks[0].GetBlocksForVerse(2, 15))
            {
                block.CharacterId = idPaul;
            }

            project.CharacterGroupGenerationPreferences.NarratorsOption = NarratorsOption.NarrationByAuthor;
            // The following can be anything but omitted, but by making them all different, we prove that
            // non-strict adherence to the the narrator prefs is really happening.
            project.DramatizationPreferences.BookTitleAndChapterDramatization = ExtraBiblicalMaterialSpeakerOption.ActorOfEitherGender;
            project.DramatizationPreferences.BookIntroductionsDramatization   = ExtraBiblicalMaterialSpeakerOption.FemaleActor;
            project.DramatizationPreferences.SectionHeadDramatization         = ExtraBiblicalMaterialSpeakerOption.MaleActor;

            var proximity = new Proximity(project, false);

            var characterIds = new HashSet <string>
            {
                CharacterVerseData.GetStandardCharacterId("GAL", CharacterVerseData.StandardCharacter.Narrator),
                CharacterVerseData.GetStandardCharacterId("GAL", CharacterVerseData.StandardCharacter.ExtraBiblical),
                CharacterVerseData.GetStandardCharacterId("GAL", CharacterVerseData.StandardCharacter.Intro),                 // Not actually used in GAL test data
                CharacterVerseData.GetStandardCharacterId("GAL", CharacterVerseData.StandardCharacter.BookOrChapter),
                idPaul
            };

            MinimumProximity minProximity = proximity.CalculateMinimumProximity(characterIds);

            Assert.AreEqual(Int32.MaxValue, minProximity.NumberOfBlocks);
        }
        public void DistributeBooksAmongNarratorGroups_ThirtySixNarrators_BottomFourAuthorsCombineIntoTwoGroups()
        {
            var narratorGroups = GetNarratorCharacterGroups(36);

            VerifyBasic(narratorGroups, 34);

            Assert.AreEqual(2, narratorGroups[34].CharacterIds.Count);
            Assert.AreEqual(2, narratorGroups[35].CharacterIds.Count);
            // Obadiah and Jude are tied for the fewest number of keystrokes. Haggai is by itself in second-to-last place.
            // Joel, Nahum, Habakkuk, Zephaniah, and Zechariah are all tied for third-to-last place.
            var bookCombinedWithHaggai = CharacterVerseData.GetBookCodeFromStandardCharacterId(narratorGroups[35].CharacterIds.Single(
                                                                                                   c => c != CharacterVerseData.GetStandardCharacterId("HAG", CharacterVerseData.StandardCharacter.Narrator)));
            string bookWhoseAuthorCombinedWithThirdToLastPlaceAuthor;

            if (bookCombinedWithHaggai == "JUD")
            {
                bookWhoseAuthorCombinedWithThirdToLastPlaceAuthor = "OBA";
            }
            else
            {
                Assert.AreEqual("OBA", bookCombinedWithHaggai);
                bookWhoseAuthorCombinedWithThirdToLastPlaceAuthor = "JUD";
            }
            var thirdToLastPlaceBookThatGotCombined = CharacterVerseData.GetBookCodeFromStandardCharacterId(
                narratorGroups[34].CharacterIds.Single(c => c != CharacterVerseData.GetStandardCharacterId(bookWhoseAuthorCombinedWithThirdToLastPlaceAuthor, CharacterVerseData.StandardCharacter.Narrator)));

            Assert.IsTrue(
                thirdToLastPlaceBookThatGotCombined == "JOL" ||
                thirdToLastPlaceBookThatGotCombined == "NAM" ||
                thirdToLastPlaceBookThatGotCombined == "HAB" ||
                thirdToLastPlaceBookThatGotCombined == "ZEP" ||
                thirdToLastPlaceBookThatGotCombined == "ZEC");
        }
Example #16
0
        public void CalculateMinimumProximity_NarrationByAuthor_CharacterSpeakingInBookHeNarratesResultsInMaxProximity()
        {
            var project = TestProject.CreateTestProject(TestProject.TestBook.GAL);

            project.UseDefaultForUnresolvedMultipleChoiceCharacters();
            var idPaul = BiblicalAuthors.GetAuthorOfBook("GAL").Name;

            foreach (var block in project.IncludedBooks[0].GetBlocksForVerse(2, 15))
            {
                block.CharacterId = idPaul;
            }

            project.CharacterGroupGenerationPreferences.NarratorsOption       = NarratorsOption.NarrationByAuthor;
            project.DramatizationPreferences.BookTitleAndChapterDramatization = ExtraBiblicalMaterialSpeakerOption.Narrator;
            project.CharacterGroupGenerationPreferences.NumberOfMaleNarrators = 1;

            var proximity = new Proximity(project);

            var characterIds = new HashSet <string>
            {
                CharacterVerseData.GetStandardCharacterId("GAL", CharacterVerseData.StandardCharacter.Narrator),
                CharacterVerseData.GetStandardCharacterId("GAL", CharacterVerseData.StandardCharacter.BookOrChapter),
                idPaul
            };

            MinimumProximity minProximity = proximity.CalculateMinimumProximity(characterIds);

            Assert.AreEqual(Int32.MaxValue, minProximity.NumberOfBlocks);
        }
Example #17
0
        public void SetBookIdForChapterBlocks_Normal_AllChapterBlocksGetBookIdSet(string chapterStyleTag)
        {
            var genesis = new BookScript("GEN",
                                         new List <Block>
            {
                CreateTestBlock(CharacterVerseData.GetStandardCharacterId("GEN", CharacterVerseData.StandardCharacter.BookOrChapter)),
                CreateChapterBlock("GEN", 1, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateChapterBlock("GEN", 2, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateChapterBlock("GEN", 3, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateChapterBlock("GEN", 4, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateTestBlock(3, MultiBlockQuote.None),
                CreateTestBlock(4, MultiBlockQuote.None),
                CreateChapterBlock("GEN", 5, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
            }
                                         );
            var matthew = new BookScript("MAT",
                                         new List <Block>
            {
                CreateTestBlock(CharacterVerseData.GetStandardCharacterId("MAT", CharacterVerseData.StandardCharacter.BookOrChapter)),
                CreateChapterBlock("MAT", 1, chapterStyleTag),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateChapterBlock("MAT", 2, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateTestBlock(3, MultiBlockQuote.None),
                CreateTestBlock(4, MultiBlockQuote.None),
                CreateChapterBlock("MAT", 3, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateChapterBlock("MAT", 4, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateChapterBlock("MAT", 5, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateChapterBlock("MAT", 6, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateChapterBlock("MAT", 20, chapterStyleTag),
                CreateTestBlock(1, MultiBlockQuote.None),
                CreateTestBlock(2, MultiBlockQuote.None),
                CreateTestBlock(3, MultiBlockQuote.None),
            }
                                         );

            var books = new List <BookScript> {
                genesis, matthew
            };

            ProjectDataMigrator.SetBookIdForChapterBlocks(books);

            Assert.IsFalse(books.SelectMany(book => book.Blocks).Where(bl => bl.StyleTag == "c" || bl.StyleTag == "cl").Any(bl => bl.BookCode == null));
        }
Example #18
0
        private void Assign_Click(object sender, EventArgs e)
        {
            if (ModifierKeys == Keys.Shift && MessageBox.Show("Are you sure you want to automatically disambiguate (for demo purposes)?", ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                var cvData = new CombinedCharacterVerseData(m_project);

                foreach (var book in m_project.IncludedBooks)
                {
                    var bookNum    = SIL.Scripture.BCVRef.BookToNumber(book.BookId);
                    int iCharacter = 0;
                    List <CharacterVerse> charactersForVerse = null;
                    foreach (var block in book.GetScriptBlocks())
                    {
                        if (block.StartsAtVerseStart)
                        {
                            iCharacter         = 0;
                            charactersForVerse = null;
                        }
                        if (block.CharacterId == CharacterVerseData.kUnknownCharacter)
                        {
                            block.SetCharacterAndCharacterIdInScript(
                                CharacterVerseData.GetStandardCharacterId(book.BookId, CharacterVerseData.StandardCharacter.Narrator), bookNum,
                                m_project.Versification);
                            block.UserConfirmed = true;
                        }
                        else if (block.CharacterId == CharacterVerseData.kAmbiguousCharacter)
                        {
                            if (charactersForVerse == null)
                            {
                                charactersForVerse = cvData.GetCharacters(bookNum, block.ChapterNumber, block.InitialStartVerseNumber,
                                                                          block.InitialEndVerseNumber, versification: m_project.Versification).ToList();
                            }

                            var cvEntry = charactersForVerse[iCharacter++];
                            if (iCharacter == charactersForVerse.Count)
                            {
                                iCharacter = 0;
                            }
                            block.SetCharacterAndCharacterIdInScript(cvEntry.Character, bookNum, m_project.Versification);
                            block.Delivery      = cvEntry.Delivery;
                            block.UserConfirmed = true;
                        }
                    }
                }
            }

            var origCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            using (var viewModel = new AssignCharacterViewModel(m_project))
                using (var dlg = new AssignCharacterDlg(viewModel))
                    dlg.ShowDialog(this);
            Cursor = origCursor;

            m_project.Analyze();
            UpdateDisplayOfProjectInfo();
            SaveCurrentProject(true);
        }
        public void DistributeBooksAmongNarratorGroups_SixSimilarAuthorsOfEightBooksAmongThreeNarrators_AuthorOfLargestBookCombinesWithShortestEtc()
        {
            var keyStrokesByBook = new Dictionary <string, int>();

            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("GEN", CharacterVerseData.StandardCharacter.Narrator)] = 50000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("ISA", CharacterVerseData.StandardCharacter.Narrator)] = 66000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JER", CharacterVerseData.StandardCharacter.Narrator)] = 52000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("EZK", CharacterVerseData.StandardCharacter.Narrator)] = 48000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("LUK", CharacterVerseData.StandardCharacter.Narrator)] = 24000;             // 52000 combined
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("ACT", CharacterVerseData.StandardCharacter.Narrator)] = 28000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JHN", CharacterVerseData.StandardCharacter.Narrator)] = 20000;             // 42000 combined
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("REV", CharacterVerseData.StandardCharacter.Narrator)] = 22000;
            var authorStats = new List <AuthorStats>();
            var moses       = new BiblicalAuthors.Author {
                Name = "Moses"
            };
            var isaiah = new BiblicalAuthors.Author {
                Name = "Isaiah"
            };
            var jeremiah = new BiblicalAuthors.Author {
                Name = "Jeremiah"
            };
            var ezekiel = new BiblicalAuthors.Author {
                Name = "Ezekiel"
            };
            var luke = new BiblicalAuthors.Author {
                Name = "Luke"
            };
            var john = new BiblicalAuthors.Author {
                Name = "John"
            };

            authorStats.Add(new AuthorStats(moses, keyStrokesByBook, "GEN"));
            authorStats.Add(new AuthorStats(isaiah, keyStrokesByBook, "ISA"));
            authorStats.Add(new AuthorStats(jeremiah, keyStrokesByBook, "JER"));
            authorStats.Add(new AuthorStats(ezekiel, keyStrokesByBook, "EZK"));
            authorStats.Add(new AuthorStats(luke, keyStrokesByBook, "LUK", "ACT"));
            authorStats.Add(new AuthorStats(john, keyStrokesByBook, "JHN", "REV"));

            var narratorGroups = GetNarratorCharacterGroups(3);

            CharacterGroupGenerator.TrialGroupConfiguration.DistributeBooksAmongNarratorGroups(authorStats, narratorGroups);

            // Since there are two authors with exactly 52000 keystrokes, we can't know for sure which one will combine with GEN and
            // which will combine with EZK. So we just assert that they are grouped properly.
            Assert.AreNotEqual(GetNarratorGroupForBook(narratorGroups, "ISA"), GetNarratorGroupForBook(narratorGroups, "JER"));
            Assert.AreNotEqual(GetNarratorGroupForBook(narratorGroups, "ISA"), GetNarratorGroupForBook(narratorGroups, "EZK"));
            Assert.AreNotEqual(GetNarratorGroupForBook(narratorGroups, "ISA"), GetNarratorGroupForBook(narratorGroups, "GEN"));
            Assert.AreNotEqual(GetNarratorGroupForBook(narratorGroups, "GEN"), GetNarratorGroupForBook(narratorGroups, "EZK"));
            Assert.AreEqual(GetNarratorGroupForBook(narratorGroups, "ISA"), GetNarratorGroupForBook(narratorGroups, "JHN"));
            Assert.AreEqual(GetNarratorGroupForBook(narratorGroups, "LUK"), GetNarratorGroupForBook(narratorGroups, "ACT"));
            Assert.AreEqual(GetNarratorGroupForBook(narratorGroups, "JHN"), GetNarratorGroupForBook(narratorGroups, "REV"));
            Assert.AreEqual(3, narratorGroups.Single(g => g.GroupId == "Narrator1").CharacterIds.Count);
            Assert.AreEqual(3, narratorGroups.Single(g => g.GroupId == "Narrator2").CharacterIds.Count);
            Assert.AreEqual(2, narratorGroups.Single(g => g.GroupId == "Narrator3").CharacterIds.Count);
        }
Example #20
0
 public AuthorStats(BiblicalAuthors.Author author, IEnumerable <string> bookIds, Dictionary <string, int> keyStrokesByCharacterId)
 {
     Author    = author;
     m_bookIds = bookIds.ToList();
     m_keyStrokesByCharacterId = keyStrokesByCharacterId;
     foreach (var bookId in m_bookIds)
     {
         KeyStrokeCount += m_keyStrokesByCharacterId[CharacterVerseData.GetStandardCharacterId(bookId, CharacterVerseData.StandardCharacter.Narrator)];
     }
 }
Example #21
0
        public void Constructor_AuthorHasNoIncludedBooks_KeyStrokeCountReturnsZero()
        {
            var keyStrokesByBook = new Dictionary <string, int>();

            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("LUK", CharacterVerseData.StandardCharacter.Narrator)] = 24000;             // 52000 combined
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("ACT", CharacterVerseData.StandardCharacter.Narrator)] = 28000;
            var includedBooks = new List <string> {
                "GEN", "ISA", "JER", "JHN", "REV"
            };

            Assert.AreEqual(0, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("LUK"), includedBooks, keyStrokesByBook).KeyStrokeCount);
        }
Example #22
0
        private Block CreateChapterBlock(string bookId, int chapter, string styleTag)
        {
            var chapterVerse = CharacterVerseData.GetStandardCharacterId(bookId, CharacterVerseData.StandardCharacter.BookOrChapter);

            return(new Block
            {
                CharacterId = chapterVerse,
                CharacterIdInScript = chapterVerse,
                StyleTag = styleTag,
                BlockElements = new List <BlockElement> {
                    new ScriptText("Chapter " + chapter)
                }
            });
        }
Example #23
0
        public AuthorStats(BiblicalAuthors.Author author, IEnumerable <string> bookIds, Dictionary <string, int> keyStrokesByCharacterId, bool includeAuthorCharacter = false)
        {
            Author    = author;
            m_bookIds = bookIds.Intersect(author.Books).ToList();
            m_keyStrokesByCharacterId = keyStrokesByCharacterId;
            foreach (var bookId in m_bookIds)
            {
                KeyStrokeCount += m_keyStrokesByCharacterId[CharacterVerseData.GetStandardCharacterId(bookId, CharacterVerseData.StandardCharacter.Narrator)];
            }

            if (includeAuthorCharacter && author.CombineAuthorAndNarrator)
            {
                KeyStrokeCount += m_keyStrokesByCharacterId[author.Name];
            }
        }
        private void AddRecordToProjectCharacterVerseData(Block block, Character character, Delivery delivery)
        {
            var cv = new CharacterVerse(
                new BCVRef(GetBlockVerseRef(block, ScrVers.English).BBBCCCVVV),
                character.IsNarrator
                                                ? CharacterVerseData.GetStandardCharacterId(CurrentBookId, CharacterVerseData.StandardCharacter.Narrator)
                                                : character.CharacterId,
                delivery.IsNormal ? null : delivery.Text,
                character.Alias,
                character.ProjectSpecific || delivery.ProjectSpecific);

            m_projectCharacterVerseData.Add(cv);

            m_project.SaveProjectCharacterVerseData();
        }
Example #25
0
        public void CalculateMinimumProximity_TreatStandardNonScriptureCharactersAsOne_ExtraBiblicalResultsInZeroProximityWithChapterNumber()
        {
            HashSet <string> characterIds = new HashSet <string>();

            characterIds.Add(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.BookOrChapter));
            characterIds.Add(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.ExtraBiblical));
            characterIds.Add(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Intro));

            MinimumProximity minProximity = m_proximity.CalculateMinimumProximity(characterIds);

            Assert.AreEqual(Int32.MaxValue, minProximity.NumberOfBlocks);
            Assert.AreEqual(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.BookOrChapter), minProximity.FirstCharacterId);
            Assert.AreEqual(minProximity.FirstCharacterId, minProximity.SecondCharacterId);
            Assert.AreEqual("MRK 0:0", minProximity.FirstReference);
            Assert.AreEqual(minProximity.FirstReference, minProximity.SecondReference);
        }
Example #26
0
        public void Constructor_BooksWithDifferentAuthors_NoStatsCombined()
        {
            var keyStrokesByBook = new Dictionary <string, int>();

            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JER", CharacterVerseData.StandardCharacter.Narrator)] = 52000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("EZK", CharacterVerseData.StandardCharacter.Narrator)] = 48000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("HOS", CharacterVerseData.StandardCharacter.Narrator)] = 12000;
            keyStrokesByBook[CharacterVerseData.GetStandardCharacterId("JUD", CharacterVerseData.StandardCharacter.Narrator)] = 1000;
            var includedBooks = new List <string> {
                "JER", "EZK", "HOS", "JUD"
            };

            Assert.AreEqual(52000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("JER"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(48000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("EZK"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(12000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("HOS"), includedBooks, keyStrokesByBook).KeyStrokeCount);
            Assert.AreEqual(1000, new AuthorStats(BiblicalAuthors.GetAuthorOfBook("JUD"), includedBooks, keyStrokesByBook).KeyStrokeCount);
        }
        public void Constructor_CharactersRemovedFromProjectLeavingGroupsThatWouldHaveNoCharacters_CharacterGroupsToRemoveNotEmpty()
        {
            // By jacking up the number of actors really high, we guarantee that most characters will end up in a group by themselves,
            // thus more-or-less ensuring that some groups will no longer contain any characters in use after excluding Mark from the
            // project.
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(99, 22, 7);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "MRK").IncludeInScript = false;
            var adjuster = new CharacterGroupsAdjuster(m_testProject);

            Assert.AreEqual(0, adjuster.CharactersNotCoveredByAnyGroup.Count());
            Assert.IsTrue(adjuster.CharactersNoLongerInUse.Contains(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(adjuster.CharactersNoLongerInUse.Contains(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(adjuster.CharactersNoLongerInUse.Contains(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.BookOrChapter)));
            Assert.IsTrue(adjuster.CharacterGroupsToRemove.Any());
            Assert.IsTrue(adjuster.GroupsAreNotInSynchWithData);
        }
Example #28
0
        public string CharacterSelect(int splitId, IEnumerable <AssignCharacterViewModel.Character> characters = null)
        {
            if ((characters == null) && !string.IsNullOrEmpty(s_characterSelect))
            {
                return(string.Format(s_characterSelect, splitId));
            }

            const string optionTemplate = "<option value=\"{0}\">{1}</option>";
            var          sb             = new StringBuilder("<select class=\"select-character\" data-splitid=\"{0}\"><option value=\"\"></option>");

            if (characters != null)
            {
                foreach (var character in characters)
                {
                    if (CharacterVerseData.IsCharacterStandard(character.CharacterId))
                    {
                    }
                    if (character.IsNarrator)
                    {
                        sb.AppendFormat(optionTemplate,
                                        CharacterVerseData.GetStandardCharacterId(BookCode, CharacterVerseData.StandardCharacter.Narrator),
                                        character.LocalizedDisplay);
                    }
                    else
                    {
                        var stdCharacterType = CharacterVerseData.GetStandardCharacterType(character.CharacterId);
                        if (stdCharacterType == CharacterVerseData.StandardCharacter.NonStandard)
                        {
                            sb.AppendFormat(optionTemplate, character.CharacterId, character.LocalizedDisplay);
                        }
                        else
                        {
                            sb.AppendFormat(optionTemplate,
                                            CharacterVerseData.GetStandardCharacterId(BookCode, stdCharacterType),
                                            character.LocalizedDisplay);
                        }
                    }
                }
            }

            sb.Append("</select>");
            s_characterSelect = sb.ToString();

            return(string.Format(s_characterSelect, splitId));
        }
        public void Constructor_CharactersAddedToProject_AdditionsButNoDeletions()
        {
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(9, 2, 1);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "ACT").IncludeInScript = true;
            var adjuster = new CharacterGroupsAdjuster(m_testProject);

            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("ACT", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("ACT", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains(CharacterVerseData.GetStandardCharacterId("ACT", CharacterVerseData.StandardCharacter.BookOrChapter)));
            Assert.IsTrue(adjuster.CharactersNotCoveredByAnyGroup.Contains("Gamaliel"));
            Assert.IsFalse(adjuster.CharactersNotCoveredByAnyGroup.Contains("Jesus"));
            Assert.IsFalse(adjuster.CharactersNotCoveredByAnyGroup.Contains("Peter (Simon)"));
            Assert.AreEqual(0, adjuster.CharactersNoLongerInUse.Count());
            Assert.AreEqual(0, adjuster.CharacterGroupsToRemove.Count());
            Assert.IsTrue(adjuster.NewBooksHaveBeenIncluded);
            Assert.IsFalse(adjuster.BooksHaveBeenExcluded);
            Assert.IsTrue(adjuster.FullRegenerateRecommended);
            Assert.IsTrue(adjuster.GroupsAreNotInSynchWithData);
        }
        public void Constructor_CharactersRemovedFromProjectButNotEnoughToResultInAnEmptyGroup_AdditionsButNoDeletions()
        {
            // By keeping the number of actors really low, we guarantee that groups will have lots of characters,
            // thus more-or-less ensuring that no groups will consist only of characters no longer in use after excluding Mark from the
            // project.
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(7, 1, 1);
            GenerateGroups();
            m_testProject.AvailableBooks.Single(b => b.Code == "MRK").IncludeInScript = false;
            var adjuster = new CharacterGroupsAdjuster(m_testProject);

            Assert.AreEqual(0, adjuster.CharactersNotCoveredByAnyGroup.Count());
            Assert.IsTrue(adjuster.CharactersNoLongerInUse.Contains(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.Narrator)));
            Assert.IsTrue(adjuster.CharactersNoLongerInUse.Contains(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.ExtraBiblical)));
            Assert.IsTrue(adjuster.CharactersNoLongerInUse.Contains(CharacterVerseData.GetStandardCharacterId("MRK", CharacterVerseData.StandardCharacter.BookOrChapter)));
            Assert.AreEqual(0, adjuster.CharacterGroupsToRemove.Count());
            Assert.IsFalse(adjuster.NewBooksHaveBeenIncluded);
            Assert.IsTrue(adjuster.BooksHaveBeenExcluded);
            Assert.IsTrue(adjuster.FullRegenerateRecommended);
            Assert.IsTrue(adjuster.GroupsAreNotInSynchWithData);
        }