Exemple #1
0
        public void DeleteCustomList_OnePossibilityReferencingCustomField_No()
        {
            // Setup
            const string newPossName = "Test Possibility";
            var          clists      = m_listRepo.Count;
            var          cfields     = Cache.MetaDataCacheAccessor.FieldCount;
            var          newPoss     = m_possFact.Create(Guid.NewGuid(), m_testList);

            newPoss.Name.set_String(m_userWs, m_tsFact.MakeString(newPossName, m_userWs));
            m_helper.ExpectedTestResponse = DialogResult.No;

            // Create a custom field in LexEntry
            var fd = CreateCustomAtomicReferenceFieldInLexEntry(m_testList.Guid);
            // Create a lexical entry
            var lexEntry = CreateLexicalEntry(Cache.LangProject.LexDbOA);

            // Create a reference to the possibility
            Cache.DomainDataByFlid.SetObjProp(lexEntry.Hvo, fd.Id, newPoss.Hvo);

            // SUT
            m_helper.Run(m_testList);

            // Verify
            Assert.AreEqual(clists, m_listRepo.Count,
                            "'User' responded 'No'. Should not have deleted the list.");
            Assert.AreEqual(cfields + 1, Cache.MetaDataCacheAccessor.FieldCount,
                            "Custom Field should not get deleted.");
            Assert.AreEqual(newPossName, m_helper.PossNameInDlg,
                            "Name of possibility found is not the one we put in there!");
            // Remove field from mdc so it doesn't mess up other tests!
            fd.MarkForDeletion = true;
            fd.UpdateCustomField();
            FieldDescription.ClearDataAbout();
        }
        private void GetCustomFieldsReferencingList(Guid listGuid)
        {
            FieldDescription.ClearDataAbout();
            var fdCollection = FieldDescription.FieldDescriptors(m_cache);

            m_customFields = new List <FieldDescription>();
            m_customFields.AddRange(from fd in fdCollection
                                    where fd.IsCustomField && fd.ListRootId == listGuid
                                    select fd);
        }
Exemple #3
0
        private void DeleteCustomField(FieldDescription fd)
        {
            // delete custom field that was added to a LexEntry for testing
            if (fd.IsCustomField && fd.IsInstalled)
            {
                fd.MarkForDeletion = true;
                AddCustomFieldDlg.UpdateCachedObjects(Cache, fd);

                Cache.ActionHandlerAccessor.BeginUndoTask("UndoUpdateCustomField", "RedoUpdateCustomField");
                fd.UpdateCustomField();
                Cache.ActionHandlerAccessor.EndUndoTask();
            }
            FieldDescription.ClearDataAbout();
        }
 private void DeleteCustomFieldsReferencingList()
 {
     // Get all the custom fields
     //GetCustomFieldsReferencingList(listGuid); now done earlier
     if (m_customFields.Count == 0)
     {
         return;
     }
     foreach (var fd in m_customFields)
     {
         fd.MarkForDeletion = true;
         fd.UpdateCustomField();
     }
     FieldDescription.ClearDataAbout();
 }