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"); }
private void AddToBestNarratorGroup(string characterId) { // Need tests (and code here) to handle the following scenarios: // 0) number of narrators > number of books -> This should never happen! // 1) DONE: number of narrators == number of books -> Add narrator to first empty narrator group // 2) TODO: number of narrators > number of authors -> break up most prolific authors into multiple narrator groups // 3) DONE: number of narrators == number of authors -> add narrator to group with other books by same other, if any; otherwise first empty group // 4) TODO: number of narrators < number of authors -> shorter books share narrators // 5) DONE: single narrator -> EASY: only one group! CharacterGroup bestNarratorGroup = null; if (m_narratorGroupsByAuthor != null) { var author = BiblicalAuthors.GetAuthorOfBook(CharacterVerseData.GetBookCodeFromStandardCharacterId(characterId)); bestNarratorGroup = m_narratorGroupsByAuthor[author]; } if (bestNarratorGroup == null) { bestNarratorGroup = NarratorGroups.FirstOrDefault(g => !g.CharacterIds.Any()); bestNarratorGroup = bestNarratorGroup ?? NarratorGroups.First(); } bestNarratorGroup.CharacterIds.Add(characterId); }