Exemplo n.º 1
0
        private MockText AddMockText(MockTextRepository mockTextRep, InterestingTextList testObj)
        {
            var newText = new MockText();

            mockTextRep.m_texts.Add(newText);
            testObj.PropChanged(newText.Hvo, TextTags.kflidContents, 0, 1, 0);
            return(newText);
        }
Exemplo n.º 2
0
        private void RemoveText(MockTextRepository mockTextRep, InterestingTextList testObj, int index)
        {
            var oldTextHvo = mockTextRep.m_texts[index].Hvo;

            ((MockText)mockTextRep.m_texts[index]).IsValidObject = false;
            ((MockStText)mockTextRep.m_texts[index].ContentsOA).IsValidObject = false;
            mockTextRep.m_texts.RemoveAt(index);
            testObj.PropChanged(oldTextHvo, TextTags.kflidContents, 0, 0, 1);
        }
Exemplo n.º 3
0
        private MockTextRepository MakeMockTextRepoWithTwoMockTexts()
        {
            var mockTextRep = new MockTextRepository();
            var mockText1   = new MockText();
            var mockText2   = new MockText();

            mockTextRep.m_texts.Add(mockText1);
            mockTextRep.m_texts.Add(mockText2);
            return(mockTextRep);
        }
Exemplo n.º 4
0
        public void GetCoreTexts()
        {
            MockTextRepository mockTextRep = MakeMockTextRepoWithTwoMockTexts();
            var testObj = new InterestingTextList(m_propertyTable, mockTextRep, m_mockStTextRepo);

            VerifyList(CurrentTexts(mockTextRep),
                       testObj.InterestingTexts, "texts from initial list of two");
            // Make sure it works if there are none.
            Assert.AreEqual(0, new InterestingTextList(m_propertyTable, new MockTextRepository(), m_mockStTextRepo).InterestingTexts.Count());
            Assert.IsTrue(testObj.IsInterestingText(mockTextRep.m_texts[0].ContentsOA));
            Assert.IsFalse(testObj.IsInterestingText(new MockStText()));
        }
Exemplo n.º 5
0
        public void PropertyTableHasInvalidObjects()
        {
            MockTextRepository mockTextRep = MakeMockTextRepoWithTwoMockTexts();

            MakeMockScriptureSection();
            m_propertyTable.SetProperty(InterestingTextList.PersistPropertyName, InterestingTextList.MakeIdList(
                                            new ICmObject[] { m_sections[0].ContentOA, m_sections[0].HeadingOA }) + "," + Convert.ToBase64String(Guid.NewGuid().ToByteArray()) + ",$%^#@+");
            var testObj = new InterestingTextList(m_propertyTable, mockTextRep, m_mockStTextRepo, true);

            testObj.InterestingTextsChanged += TextsChangedHandler;
            var expectedScripture = new List <IStText>();

            expectedScripture.Add(m_sections[0].ContentOA);
            expectedScripture.Add(m_sections[0].HeadingOA);
            VerifyList(expectedScripture, testObj.ScriptureTexts, "Just two valid Guids");
        }
Exemplo n.º 6
0
        public void ReplaceCoreText()
        {
            MockTextRepository mockTextRepo = MakeMockTextRepoWithTwoMockTexts();
            var      testObj     = new InterestingTextList(m_propertyTable, mockTextRepo, m_mockStTextRepo);
            var      firstStText = testObj.InterestingTexts.First();
            MockText firstText   = firstStText.Owner as MockText;
            var      replacement = new MockStText();

            testObj.InterestingTextsChanged += TextsChangedHandler;
            firstText.ContentsOA             = replacement;
            testObj.PropChanged(firstText.Hvo, TextTags.kflidContents, 0, 1, 1);

            VerifyList(CurrentTexts(mockTextRepo),
                       testObj.InterestingTexts, "texts after replace");
            // Various possibilities could be valid for the arguments...for now just verify we got something.
            Assert.That(m_lastTextsChangedArgs, Is.Not.Null);
        }
Exemplo n.º 7
0
        public void AddAndRemoveCoreTexts()
        {
            MockTextRepository mockTextRep = MakeMockTextRepoWithTwoMockTexts();
            var testObj = new InterestingTextList(m_propertyTable, mockTextRep, m_mockStTextRepo);

            Assert.AreEqual(0, testObj.ScriptureTexts.Count());
            testObj.InterestingTextsChanged += TextsChangedHandler;
            MockText newText = AddMockText(mockTextRep, testObj);

            VerifyList(CurrentTexts(mockTextRep),
                       testObj.InterestingTexts, "texts from initial list of two");
            VerifyTextsChangedArgs(2, 1, 0);
            var removed = mockTextRep.m_texts[1].ContentsOA;

            RemoveText(mockTextRep, testObj, 1);
            VerifyList(CurrentTexts(mockTextRep),
                       testObj.InterestingTexts, "texts from initial list of two");
            VerifyTextsChangedArgs(1, 0, 1);
            Assert.IsTrue(testObj.IsInterestingText(mockTextRep.m_texts[1].ContentsOA), "text not removed still interesting");
            Assert.IsFalse(testObj.IsInterestingText(removed), "removed text no longer interesting");
        }
Exemplo n.º 8
0
        private InterestingTextList SetupTwoMockTextsAndOneScriptureSection(bool fIncludeScripture, out List <IStText> expectedScripture,
                                                                            out List <IStText> expected)
        {
            MockTextRepository mockTextRep = MakeMockTextRepoWithTwoMockTexts();

            MakeMockScriptureSection();
            m_propertyTable.SetProperty(InterestingTextList.PersistPropertyName, InterestingTextList.MakeIdList(
                                            new ICmObject[] { m_sections[0].ContentOA, m_sections[0].HeadingOA }));
            var testObj = new InterestingTextList(m_propertyTable, mockTextRep, m_mockStTextRepo, fIncludeScripture);

            testObj.InterestingTextsChanged += TextsChangedHandler;
            expectedScripture = new List <IStText>();
            expectedScripture.Add(m_sections[0].ContentOA);
            expectedScripture.Add(m_sections[0].HeadingOA);
            VerifyScriptureList(testObj, expectedScripture, "Initially two Scripture texts");

            expected = new List <IStText>(CurrentTexts(mockTextRep));
            if (fIncludeScripture)
            {
                expected.AddRange(expectedScripture);
            }
            VerifyList(expected, testObj.InterestingTexts, "two ordinary and two Scripture texts");
            return(testObj);
        }
Exemplo n.º 9
0
 private List <IStText> CurrentTexts(MockTextRepository mockTextRep)
 {
     return((from text in mockTextRep.m_texts select text.ContentsOA).ToList());
 }