SetInterestingTexts() public method

This routine is where InterlinMaster sends the results of running the IFilterTextsDialog. The list may include regular as well as scripture texts. We persist them separately because Scripture is excluded by default and regular texts are included by default. Thus, storing a list of the INCLUDED scripture means that originally, or if we clear all saved settings, NO scripture is included, and any newly created Scripture is also excluded until manually added. Storing a lis of EXCLUDED regular texts means that originally, or if we clear all saved settings, ALL regular texts are included, and if we add a new one, it is automatically included.
public SetInterestingTexts ( IEnumerable stTexts ) : void
stTexts IEnumerable
return void
コード例 #1
0
 public void SetInterestingTexts(IEnumerable <IStText> newTexts)
 {
     m_interestingTexts.SetInterestingTexts(newTexts);
 }
コード例 #2
0
        public void AddAndRemoveScripture()
        {
            List <IStText>      expectedScripture;
            List <IStText>      expected;
            InterestingTextList testObj = SetupTwoMockTextsAndOneScriptureSection(true, out expectedScripture, out expected);

            MakeMockScriptureSection();
            testObj.PropChanged(m_sections[1].Hvo, ScrSectionTags.kflidContent, 0, 1, 0);
            testObj.PropChanged(m_sections[1].Hvo, ScrSectionTags.kflidHeading, 0, 1, 0);
            VerifyList(expected, testObj.InterestingTexts, "new Scripture objects are not added automatically");
            VerifyScriptureList(testObj, expectedScripture, "new Scripture objects are not added automatically to ScriptureTexts");
            Assert.IsTrue(testObj.IsInterestingText(expectedScripture[0]));
            Assert.IsTrue(testObj.IsInterestingText(expectedScripture[1]));

            var remove = ((MockStText)m_sections[0].ContentOA);

            remove.IsValidObject = false;
            expected.Remove(m_sections[0].ContentOA);   // before we clear ContentsOA!
            expectedScripture.Remove(m_sections[0].ContentOA);
            m_sections[0].ContentOA = null;             // not normally valid, but makes things somewhat more consistent for test.
            testObj.PropChanged(m_sections[0].Hvo, ScrSectionTags.kflidContent, 0, 0, 1);
            VerifyList(expected, testObj.InterestingTexts, "deleted Scripture texts are removed (ContentsOA)");
            VerifyScriptureList(testObj, expectedScripture, "deleted Scripture texts are removed from ScriptureTexts (ContentsOA");
            VerifyTextsChangedArgs(2, 0, 1);
            Assert.IsFalse(testObj.IsInterestingText(remove));
            Assert.IsTrue(testObj.IsInterestingText(expectedScripture[0]));

            ((MockStText)m_sections[0].HeadingOA).IsValidObject = false;
            expected.Remove(m_sections[0].HeadingOA);   // before we clear ContentsOA!
            m_sections[0].HeadingOA = null;             // not normally valid, but makes things somewhat more consistent for test.
            testObj.PropChanged(m_sections[0].Hvo, ScrSectionTags.kflidHeading, 0, 0, 1);
            VerifyList(expected, testObj.InterestingTexts, "deleted Scripture texts are removed (HeadingOA)");

            m_sections[0].ContentOA = new MockStText();
            var newTexts = new IStText[] { expected[0], expected[1], m_sections[0].ContentOA, m_sections[1].ContentOA, m_sections[1].HeadingOA };

            testObj.SetInterestingTexts(newTexts);
            VerifyTextsChangedArgs(2, 3, 0);
            expected.AddRange(new[] { m_sections[0].ContentOA, m_sections[1].ContentOA, m_sections[1].HeadingOA });
            VerifyList(expected, testObj.InterestingTexts, "deleted Scripture texts are removed (HeadingOA)");
            // Unfortunately, I don't think we actually get PropChanged on the direct owning property,
            // if the owning object (Text or ScrSection) gets deleted. We need to detect deleted objects
            // if things are deleted from any of the possible owning properties.
            // This is also a chance to verify that being owned by an ScrDraft does not count as valid.
            // It's not a very realistic test, as we aren't trying to make everything about the test data consistent.
            ((MockStText)m_sections[0].ContentOA).m_mockOwnerOfClass = new MockScrDraft();              // not allowed in list.
            testObj.PropChanged(m_sections[0].Hvo, ScrBookTags.kflidSections, 0, 0, 1);
            expected.RemoveAt(2);
            VerifyList(expected, testObj.InterestingTexts, "deleted Scripture texts are removed (ScrBook.SectionsOS)");
            VerifyTextsChangedArgs(2, 0, 1);

            ((MockStText)expected[3]).IsValidObject = false;
            expected.RemoveAt(3);
            testObj.PropChanged(m_sections[0].Hvo, ScriptureTags.kflidScriptureBooks, 0, 0, 1);
            VerifyList(expected, testObj.InterestingTexts, "deleted Scripture texts are removed (Scripture.ScriptureBooks)");
            VerifyTextsChangedArgs(3, 0, 1);

            ((MockStText)expected[2]).IsValidObject = false;
            expected.RemoveAt(2);
            testObj.PropChanged(m_sections[0].Hvo, ScrBookTags.kflidTitle, 0, 0, 1);
            VerifyList(expected, testObj.InterestingTexts, "deleted Scripture texts are removed (ScrBookTags.Title)");
            VerifyTextsChangedArgs(2, 0, 1);
            Assert.AreEqual(0, testObj.ScriptureTexts.Count(), "by now we've removed all ScriptureTexts");

            ((MockStText)expected[1]).IsValidObject = false;
            expected.RemoveAt(1);
            //testObj.PropChanged(1, LangProjectTags.kflidTexts, 0, 0, 1);
            VerifyList(expected, testObj.InterestingTexts, "deleted texts are removed (LangProject.Texts)");
            VerifyTextsChangedArgs(1, 0, 1);
        }