public void GetSortedAndFilteredReversalEntries_ExcludesSubentriesAndUnpublishable() { // This test relies on the objects set up during the test FixtureSetup Mediator.PropertyTable.SetProperty("currentContentControl", "reversalToolEditComplete"); Mediator.PropertyTable.SetProperty("ReversalIndexGuid", m_revIndex.Guid.ToString()); Assert.AreEqual(6, m_revDecorator.VecProp(m_revIndex.Hvo, ObjectListPublisher.OwningFlid).Length, "there should be 6 Reversal Entries and Sub[sub]entries"); var entries = m_revDecorator.GetEntriesToPublish(Mediator, ObjectListPublisher.OwningFlid, "Reversal Index"); // "Reversal Form" is linked to m_nolanryan which is excluded from publication Assert.AreEqual(2, entries.Length, "there should be only 2 main Reversal Entry that can be published"); var entry = Cache.ServiceLocator.GetObject(entries[0]) as IReversalIndexEntry; Assert.IsNotNull(entry, "the single reversal entry really is a reversal entry"); Assert.AreEqual("Reversal 2 Form", entry.ShortName, "'Reversal 2 Form' is the sole publishable main reversal entry"); Assert.AreEqual(2, entry.SubentriesOS.Count, "'Reversal 2 Form' has two subentries"); // "Reversal 2a Form" is linked to m_water2 which is excluded from publication var vec = m_revDecorator.VecProp(entry.Hvo, ReversalIndexEntryTags.kflidSubentries); Assert.AreEqual(1, vec.Length, "Only one of the subentries is publishable"); var subentry = Cache.ServiceLocator.GetObject(vec[0]) as IReversalIndexEntry; Assert.AreEqual("Reversal 2b Form", subentry.ShortName, "'Reversal 2b Form' is the only publishable subentry of 'Reversal 2 Form'"); Assert.IsTrue(m_revDecorator.IsExcludedObject(entry.SubentriesOS[0]), "First subentry ('Reversal 2a Form') should be excluded"); Assert.IsFalse(m_revDecorator.IsExcludedObject(entry.SubentriesOS[1]), "Second subentry ('Reversal 2b Form') should not be excluded')"); }
public void SimpleFiltering() { // Try all the variants of retrieving a vector property. var sensesOfHot = m_decorator.VecProp(m_hot.Hvo, LexEntryTags.kflidSenses); Assert.That(sensesOfHot.Length, Is.EqualTo(2), "one bad sense should be eliminated."); Assert.That(sensesOfHot[0], Is.EqualTo(m_hot.SensesOS[0].Hvo)); Assert.That(sensesOfHot[1], Is.EqualTo(m_desirable.Hvo)); Assert.That(m_decorator.get_VecSize(m_hot.Hvo, LexEntryTags.kflidSenses), Is.EqualTo(2)); Assert.That(m_decorator.get_VecItem(m_hot.Hvo, LexEntryTags.kflidSenses, 1), Is.EqualTo(m_desirable.Hvo)); // This test is perhaps redundant here: DictionaryPublicationDecorator does not have to do anything to get this behavior. using (ArrayPtr arrayPtr = MarshalEx.ArrayToNative <int>(2)) { int chvo; m_decorator.VecProp(m_hot.Hvo, LexEntryTags.kflidSenses, 2, out chvo, arrayPtr); var values = MarshalEx.NativeToArray <int>(arrayPtr, 2); Assert.That(values[0], Is.EqualTo(m_hot.SensesOS[0].Hvo)); Assert.That(values[1], Is.EqualTo(m_desirable.Hvo)); } // This verifies both that examples are included in the bad objects, and that properties // that point at examples are automatically excluded. var hotTempExamples = m_decorator.VecProp(m_hotTemp.Hvo, LexSenseTags.kflidExamples); Assert.That(hotTempExamples.Length, Is.EqualTo(1)); Assert.That(hotTempExamples[0], Is.EqualTo(m_goodHot.Hvo)); // They should be filtered also from certain properties with CmObject signatures. var hotWaterComponents = m_decorator.VecProp(m_hotWaterComponents.Hvo, LexEntryRefTags.kflidComponentLexemes); Assert.That(hotWaterComponents.Length, Is.EqualTo(1)); Assert.That(hotWaterComponents[0], Is.EqualTo(m_waterH2O.Hvo)); // More cursory checks...there are many of these. Assert.That(m_decorator.VecProp(m_hotWaterComponents.Hvo, LexEntryRefTags.kflidPrimaryLexemes).Length, Is.EqualTo(1)); // As well as checking that LexReference.Targets is filtered, this checks that we filter senses of excluded entries, // and that it really is possible for more than one thing to pass the filter. Assert.That(m_decorator.VecProp(m_blankSynonyms.Hvo, LexReferenceTags.kflidTargets).Length, Is.EqualTo(2)); // They should be filtered from the top-level list of entries managed by the wrapped decorator var mainEntryList = m_decorator.VecProp(Cache.LangProject.LexDbOA.Hvo, ObjectListPublisher.OwningFlid); Assert.That(mainEntryList.Length, Is.EqualTo(Cache.LangProject.LexDbOA.Entries.Where( le => le.DoNotPublishInRC.Count == 0 && le.DoNotShowMainEntryInRC.Count == 0).Count())); }