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 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 FullyRegenerateGroups_CameoGroupsWithCharactersNoLongerInUse_GroupsRegenerated()
        {
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = true;
            m_testProject.VoiceActorList.Actors = CharacterGroupGeneratorTests.GetVoiceActors(290, 17, 8);
            GenerateGroups();
            var frankie = m_testProject.VoiceActorList.Actors.First(a => a.Gender == ActorGender.Male);

            frankie.Name    = "Frankie";
            frankie.IsCameo = true;
            var michaelTheArchAngelGroup = m_testProject.CharacterGroupList.GroupContainingCharacterId("Michael, archangel");

            michaelTheArchAngelGroup.AssignVoiceActor(frankie.Id);
            m_testProject.AvailableBooks.Single(b => b.Code == "JUD").IncludeInScript = false;
            var adjuster           = new CharacterGroupsAdjuster(m_testProject);
            var charactersNotInUse = adjuster.CharactersNoLongerInUse.ToList();

            Assert.IsTrue(charactersNotInUse.Contains("Michael, archangel"));
            var originalCountOfGroups = m_testProject.CharacterGroupList.CharacterGroups.Count;
            var groupsToRemove        = adjuster.CharacterGroupsToRemove.ToList();

            Assert.AreEqual(1, groupsToRemove.Count);
            Assert.IsFalse(groupsToRemove.Contains(michaelTheArchAngelGroup));

            adjuster.FullyRegenerateGroups();
            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);
            var frankieGroup = m_testProject.CharacterGroupList.GetGroupsAssignedToActor(frankie.Id).First();

            Assert.AreEqual(frankieGroup, m_testProject.CharacterGroupList.CharacterGroups.Single(g => !g.CharacterIds.Any()));
            Assert.IsFalse(m_testProject.CharacterGroupList.CharacterGroups.Any(g => 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);
        }
Exemple #4
0
        private void EnsureGroupsAreInSynchWithCharactersInUse()
        {
            if (!m_project.CharacterGroupList.CharacterGroups.Any())
            {
                return;
            }
            var adjuster = new CharacterGroupsAdjuster(m_project);

            if (adjuster.GroupsAreNotInSynchWithData)
            {
                string dlgMessage = String.Format(LocalizationManager.GetString("DialogBoxes.GroupsAreNotInSynchWithData.Message",
                                                                                "There have been changes to this project. The character groups no longer match the characters. {0} must update the groups in one of two ways:" +
                                                                                Environment.NewLine + Environment.NewLine +
                                                                                "{0} can start fresh, optimizing the number and composition of character groups based on the characters in the script and the voice actors in this project. " +
                                                                                "This is usually the recommended option." +
                                                                                "However, if the previously generated groups were manually changed most of these changes will probably be lost." +
                                                                                Environment.NewLine + Environment.NewLine +
                                                                                "Alternatively, {0} can just make the minimal changes to remove unused characters and put any new characters in a single group. This will probably require " +
                                                                                "substantial manual customization to avoid problems. If this proves too difficult, the groups can be re-optimized later by clicking {1} in the {2} dialog box." +
                                                                                Environment.NewLine + Environment.NewLine +
                                                                                "Would you like {0} to do the recommended action and create new character groups now?"),
                                                  ProductName,
                                                  LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.ToolStrip.UpdateCharacterGroups",
                                                                                "Update Character Groups...").TrimEnd('.'),
                                                  LocalizationManager.GetString("DialogBoxes.VoiceActorAssignmentDlg.WindowTitle", "Voice Actor Assignment"));

                if (MessageBox.Show(dlgMessage, ProductName, MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    using (var progressDialog = new GenerateGroupsProgressDialog(m_project, (s, e) => adjuster.FullyRegenerateGroups(), false))
                        progressDialog.ShowDialog();
                }
                else
                {
                    adjuster.MakeMinimalAdjustments();
                }
            }
        }