public void UtilityToCalculateMinimumCastSizesForAcholi_ThisIsNotARealUnitTest(string bookCode, int initialGuess) { foreach (var book in m_project.AvailableBooks) { book.IncludeInScript = book.Code == bookCode; } m_project.ClearCharacterStatistics(); CastSizeRowValues validCast = new CastSizeRowValues(initialGuess + 2, 2, 1); var currentCast = new CastSizeRowValues(initialGuess + 1, 2, 1); List <CharacterGroup> groups; do { var gen = new CharacterGroupGenerator(m_project, currentCast); groups = gen.GenerateCharacterGroups(true); if (groups != null) { validCast.Male = currentCast.Male; } currentCast.Male--; } while (groups != null && currentCast.Male >= 2); Assert.IsTrue(validCast.Male <= initialGuess + 1); m_results[bookCode] = validCast; }
public void GeneratePossibilities_OneMaleActorOneFemaleActorOneChildActor_DoesNotThrow(bool fallbackPass) { m_testProject.CharacterGroupGenerationPreferences.NumberOfMaleNarrators = 1; m_testProject.CharacterGroupGenerationPreferences.NumberOfFemaleNarrators = 0; m_testProject.CharacterGroupGenerationPreferences.IsSetByUser = true; SetVoiceActors(1, 1, 1); var gen = new CharacterGroupGenerator(m_testProject); var groups = gen.GenerateCharacterGroups(); var maxMaleNarrators = 2; // one per book var maxFemaleNarrators = 0; var characterDetails = m_testProject.AllCharacterDetailDictionary; var includedCharacterDetails = characterDetails.Values.Where(c => m_testProject.AllCharacterIds.Contains(c.CharacterId)).ToList(); // Adult groups are already assigned to actors because they are exclusive matches for their respective characterIds. // GeneratePossibilities assumes each group has an actor assigned, so we make the final assignment here. groups.Single(g => g.GroupIdLabel == CharacterGroup.Label.Child).AssignVoiceActor(m_testProject.VoiceActorList.AllActors.Single(a => a.Age == ActorAge.Child).Id); Assert.DoesNotThrow(() => CharacterGroupGenerator.TrialGroupConfiguration.GeneratePossibilities( fallbackPass, groups, maxMaleNarrators, maxFemaleNarrators, true, includedCharacterDetails, m_testProject.KeyStrokesByCharacterId, m_testProject, characterDetails, m_testProject.DramatizationPreferences ) ); }
private void GenerateGroups() { var generator = new CharacterGroupGenerator(m_testProject); generator.GenerateCharacterGroups(); generator.ApplyGeneratedGroupsToProject(); }
public void GetMultiColumnActorDataTable_ActorAssigned_AssignedActorSortsLast() { var actorB = new Glyssen.VoiceActor.VoiceActor { Id = 1, Name = "B" }; var actorC = new Glyssen.VoiceActor.VoiceActor { Id = 2, Name = "C" }; var actorA = new Glyssen.VoiceActor.VoiceActor { Id = 3, Name = "A" }; m_testProject.VoiceActorList.AllActors = new List <Glyssen.VoiceActor.VoiceActor> { actorB, actorC, actorA }; var generator = new CharacterGroupGenerator(m_testProject); generator.GenerateCharacterGroups(); generator.ApplyGeneratedGroupsToProject(false); var group = m_model.CharacterGroups[0]; m_model.AssignActorToGroup(actorA.Id, group); var dataTable = m_model.GetMultiColumnActorDataTable(m_model.CharacterGroups[0]); var actorList = GetActorListFromDataTable(dataTable); Assert.AreEqual(actorB, actorList[0]); Assert.AreEqual(actorC, actorList[1]); Assert.AreEqual(null, actorList[2]); // The "Unassigned" option Assert.AreEqual(actorA, actorList[3]); }
private void AssignVoiceActors_Click(object sender, EventArgs e) { // TODO: Eventually, this should be called when the user requests that all overrides be reverted to the defaults. //m_project.UseDefaultForUnresolvedMultipleChoiceCharacters(); bool regenerateGroups = sender == m_btnCastSizePlanning; if (!regenerateGroups) { EnsureGroupsAreInSynchWithCharactersInUse(); } if (!m_project.CharacterGroupList.CharacterGroups.Any()) { CharacterGroupGenerator.GenerateGroupsWithProgress(m_project, false, true, false, ProjectCastSizePlanningViewModel.SelectedCastSize); } else if (regenerateGroups) { CharacterGroupGenerator.GenerateGroupsWithProgress(m_project, true, false, false, ProjectCastSizePlanningViewModel.SelectedCastSize); } bool launchCastSizePlanning; using (var dlg = new VoiceActorAssignmentDlg(new VoiceActorAssignmentViewModel(m_project))) { ShowModalDialogWithWaitCursor(dlg); launchCastSizePlanning = dlg.LaunchCastSizePlanningUponExit; } SaveCurrentProject(); UpdateDisplayOfProjectInfo(); if (launchCastSizePlanning) { m_btnCastSizePlanning_Click(m_btnCastSizePlanning, new EventArgs()); } }
private void EnsureGroupsAreInSynchWithCharactersInUse() { if (!m_project.CharacterGroupList.CharacterGroups.Any()) { return; } var adjuster = new CharacterGroupsAdjuster(m_project); if (adjuster.GroupsAreNotInSynchWithData) { using (var progressDialog = new GenerateGroupsProgressDialog(m_project, OnGenerateGroupsWorkerDoWork, false, true)) { var generator = new CharacterGroupGenerator(m_project, ProjectCastSizePlanningViewModel.SelectedCastSize, progressDialog.BackgroundWorker); progressDialog.ProgressState.Arguments = generator; if (progressDialog.ShowDialog() == DialogResult.OK && generator.GeneratedGroups != null) { var assignedBefore = m_project.CharacterGroupList.CountVoiceActorsAssigned(); generator.ApplyGeneratedGroupsToProject(); if (m_project.CharacterGroupList.CountVoiceActorsAssigned() < assignedBefore) { var msg = LocalizationManager.GetString("MainForm.FewerAssignedActorsAfterGeneration", "An actor assignment had to be removed. Please review the Voice Actor assignments, and adjust where necessary."); MessageBox.Show(this, msg, Text, MessageBoxButtons.OK); } } else { adjuster.MakeMinimalAdjustments(); } m_project.Save(true); } } // This is for the migration of old projects. // ENHANCE; Theoretically, we could, before we update the controlfileversion number, set a flag // letting us know if this needs to run or not. It would be for any number < 96. // This method would be moved into Project (which maybe it should be anyway). // But this must be called only AFTER EnsureGroupsAreInSynchWithCharactersInUse has been run. if (m_project.CharacterGroupList.CharacterGroups.Any(g => g.GroupIdLabel == CharacterGroup.Label.None)) { CharacterGroupList.AssignGroupIds(m_project.CharacterGroupList.CharacterGroups); } }
public void UtilityToCalculateMinimumCastSizesForKuna_ThisIsNotARealUnitTest(string bookCode, int initialGuess) { if (bookCode == "SNG") { // Song of Solomon is special because all the speech is "Implicit" (which we don't handle properly yet) m_results[bookCode] = new CastSizeRowValues(4, 2, 0); return; } foreach (var book in m_project.AvailableBooks) { book.IncludeInScript = book.Code == bookCode; } m_project.IncludedBooks.Single().SingleVoice = false; m_project.ClearCharacterStatistics(); var women = (bookCode == "RUT") ? 4 : 2; if (bookCode == "GEN" || bookCode == "EXO") { women = 3; } CastSizeRowValues validCast = new CastSizeRowValues(initialGuess + 2, women, 1); var currentCast = new CastSizeRowValues(initialGuess + 1, women, 1); List <CharacterGroup> groups = null; do { var gen = new CharacterGroupGenerator(m_project, currentCast); groups = gen.GenerateCharacterGroups(true); if (groups != null) { validCast.Male = currentCast.Male; } currentCast.Male--; } while (groups != null && currentCast.Male >= 2); Assert.IsTrue(validCast.Male <= initialGuess + 1); m_results[bookCode] = validCast; }