public void GetMatchesByKey_HasAnnotationWithoutRef_DoesntCrash() { using (var r = AnnotationRepository.FromString("id", @"<notes version='0'></notes>")) { r.AddAnnotation(new Annotation("question", "lift://blah.lift", "somepath")); var index = new SubClassForTest("id"); r.AddObserver(index, _progress); Assert.AreEqual(0, index.GetMatchesByKey("222").Count()); } }
public void Remove_IndexAddedAfterRepoConstruction_RemovesIt() { using (var r = AnnotationRepository.FromString("id", @"<notes version='0'> <annotation class='note' ref='blah://blah?id=blue'/> </notes>")) { var index = new SubClassForTest("id"); r.AddObserver(index, _progress); var blues = index.GetMatchesByKey("blue"); r.Remove(blues.First()); blues = index.GetMatchesByKey("blue"); Assert.AreEqual(0, blues.Count(), "should be none left"); } }
public void Remove_2AnnotationsWithSameTarget_OnlyRemoves1FromIndex() { using (var r = AnnotationRepository.FromString("id", @"<notes version='0'> <annotation class='question' ref='blah://blah?id=blue'/> <annotation class='note' ref='blah://blah?id=blue'/> </notes>")) { var index = new SubClassForTest("id"); r.AddObserver(index, _progress); var blues = index.GetMatchesByKey("blue"); r.Remove(blues.First()); blues = index.GetMatchesByKey("blue"); Assert.AreEqual(1, blues.Count(), "should be one left"); } }