public PropChanged ( int hvo, int tag, int ivMin, int cvIns, int cvDel ) : void | ||
hvo | int | |
tag | int | |
ivMin | int | |
cvIns | int | |
cvDel | int | |
리턴 | void |
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); }
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); }
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); }
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); }