public void CheckboxBehavior_SelectParentsThatWereNotInOwnershipTreeOfChildList() { m_bulkEditBar.SwitchTab("BulkCopy"); m_bv.ShowColumn("ExampleTranslation"); m_bulkEditBar.SetTargetField("Example Translations"); RecordClerk clerk = (m_bv.Parent as RecordBrowseViewForTests).Clerk; // having fewer translations than parent entries is strange // but it's currently the only way we can allow bulk editing translations. // We can allow ghosting for Examples that don't have translations // but not for a translation of a ghosted (not-yet existing) Example. Assert.Less(clerk.ListSize, Cache.LangProject.LexDbOA.EntriesOC.Count); // Uncheck everything before we switch to parent list m_bv.OnUncheckAll(); IList<int> uncheckedTranslationItems = m_bv.UncheckedItems(); Assert.AreEqual(uncheckedTranslationItems.Count, clerk.ListSize); // go through each of the translation items, and find the LexEntry owner. IDictionary<int, int> translationsToEntries = GetParentOfClassMap(uncheckedTranslationItems, LexEntry.kclsidLexEntry); Set<int> expectedUnselectedEntries = new Set<int>(translationsToEntries.Values); // Now switch to Entries and expect the new parent items to be selected. using (FilterBehavior.Create(this)) m_bulkEditBar.SetTargetField("Lexeme Form"); Set<int> entriesSelected = new Set<int>(m_bv.CheckedItems); Set<int> entriesUnselected = new Set<int>(m_bv.UncheckedItems()); Assert.AreEqual(expectedUnselectedEntries.Count, entriesUnselected.Count, "Unselected items mismatched."); Assert.IsTrue(expectedUnselectedEntries.Equals(entriesUnselected), "Unselected items mismatched."); Assert.Greater(entriesSelected.Count, 0); }
public void CheckboxBehavior_SiblingClassesItemsShouldInheritSelectionThroughParent_UnSelected() { // first create an entry with a pronunciation and some senses. ILexPronunciation pronunciation; ILexEntry parentEntry = CreateZZZparentEntryWithMultipleSensesAndPronunciation(out pronunciation); m_bulkEditBar.SwitchTab("BulkCopy"); m_bv.ShowColumn("Pronunciation"); m_bulkEditBar.SetTargetField("Pronunciations"); RecordClerk clerk = (m_bv.Parent as RecordBrowseViewForTests).Clerk; // go through each of the pronunciation items, and find the LexEntry owner. IDictionary<int, int> pronunciationsToEntries = GetParentOfClassMap(m_bv.AllItems, LexEntry.kclsidLexEntry); // Unselect one sibling m_bv.UnselectItem(pronunciation.Hvo); // now switch to (sense) sibling list using (FilterBehavior.Create(this)) m_bulkEditBar.SetTargetField("Glosses"); // validate that only the siblings are unselected. Set<int> hvoSenseSiblings = new Set<int>(FdoVectorUtils.ConvertCmObjectsToHvos<ILexSense>(parentEntry.AllSenses)); Set<int> uncheckedItems = new Set<int>(m_bv.UncheckedItems()); Assert.AreEqual(hvoSenseSiblings.Count, uncheckedItems.Count); Assert.IsTrue(hvoSenseSiblings.Equals(uncheckedItems)); }
public void CheckboxBehavior_ParentClassesItemsShouldInheritSelection_Selected() { // find a lex entry that has multiple senses (i.e. descendents). ILexEntry entryWithMultipleDescendents = CreateZZZparentEntryWithMultipleSensesAndPronunciation_AndUpdateList(); // some entries (like variants) don't have senses, so we need to factor those into our results. ICollection<ILexEntry> entriesWithoutSenses = FindEntriesWithoutSenses(); m_bulkEditBar.SwitchTab("BulkCopy"); m_bulkEditBar.SetTargetField("Glosses"); Assert.AreEqual(LexSense.kclsidLexSense, m_bv.ListItemsClass); RecordClerk clerk = (m_bv.Parent as RecordBrowseViewForTests).Clerk; m_bv.OnUncheckAll(); // select the sense. m_bv.SetCheckedItems(new int[] { entryWithMultipleDescendents.AllSenses[0].Hvo }); using (FilterBehavior.Create(this)) m_bulkEditBar.SetTargetField("Lexeme Form"); Set<int> selectedEntries = new Set<int>(new int[] {entryWithMultipleDescendents.Hvo}); selectedEntries.AddRange(FdoVectorUtils.ConvertCmObjectsToHvos<ILexEntry>(entriesWithoutSenses)); Set<int> checkedItems = new Set<int>(m_bv.CheckedItems); Assert.AreEqual(selectedEntries.Count, checkedItems.Count, "Checked items mismatched."); Assert.IsTrue(checkedItems.Equals(selectedEntries), "Checked items mismatched."); }
public void CheckboxBehavior_ParentClassesItemsShouldInheritSelection_UnSelected() { // find a lex entry that has multiple senses (i.e. descendents). ILexEntry entryWithMultipleDescendents = CreateZZZparentEntryWithMultipleSensesAndPronunciation_AndUpdateList(); m_bulkEditBar.SwitchTab("BulkCopy"); m_bulkEditBar.SetTargetField("Glosses"); Assert.AreEqual(LexSense.kclsidLexSense, m_bv.ListItemsClass); RecordClerk clerk = (m_bv.Parent as RecordBrowseViewForTests).Clerk; // unselect all the senses belonging to this entry m_bv.UncheckItems(FdoVectorUtils.ConvertCmObjectsToHvos<ILexSense>(entryWithMultipleDescendents.AllSenses)); // switch to the parent list using (FilterBehavior.Create(this)) m_bulkEditBar.SetTargetField("Lexeme Form"); Set<int> unselectedEntries = new Set<int>(new int[] { entryWithMultipleDescendents.Hvo }); Set<int> uncheckedItems = new Set<int>(m_bv.UncheckedItems()); Assert.AreEqual(unselectedEntries.Count, uncheckedItems.Count, "Unchecked items mismatched."); Assert.IsTrue(uncheckedItems.Equals(unselectedEntries), "Unchecked items mismatched."); }
public virtual void CheckboxBehavior_DescendentItemsShouldInheritSelection_Select() { // find a lex entry that has multiple senses (i.e. descendents). ILexEntry entryWithMultipleDescendents = CreateZZZparentEntryWithMultipleSensesAndPronunciation_AndUpdateList(); m_bulkEditBar.SwitchTab("BulkCopy"); m_bulkEditBar.SetTargetField("Lexeme Form"); Assert.AreEqual(LexEntry.kclsidLexEntry, m_bv.ListItemsClass); m_bv.OnUncheckAll(); // select the entry. m_bv.SetCheckedItems(new List<int>(new int[] {entryWithMultipleDescendents.Hvo})); using (FilterBehavior.Create(this)) m_bulkEditBar.SetTargetField("Glosses"); Set<int> allSensesForEntry = new Set<int>( FdoVectorUtils.ConvertCmObjectsToHvos<ILexSense>(entryWithMultipleDescendents.AllSenses)); Set<int> checkedItems = new Set<int>(m_bv.CheckedItems); Assert.AreEqual(allSensesForEntry.Count, checkedItems.Count, "Checked items mismatched."); Assert.IsTrue(checkedItems.Equals(allSensesForEntry), "Checked items mismatched."); }