コード例 #1
0
        public void AddIndex_CallInitializeOnIndex()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'><annotation guid='123'>
<message guid='234'>&lt;p&gt;hello</message></annotation></notes>"))
            {
                var index = new TestAnnotationIndex();
                r.AddObserver(index, _progress);
                Assert.AreEqual(1, index.InitialItems);
            }
        }
コード例 #2
0
 public void AddIndex_CallInitializeOnIndex()
 {
     using (var r = AnnotationRepository.FromString("id", @"<notes version='0'><annotation guid='123'>
     <message guid='234'>&lt;p&gt;hello</message></annotation></notes>"))
     {
         var index = new TestAnnotationIndex();
         r.AddObserver(index, _progress);
         Assert.AreEqual(1, index.InitialItems);
     }
 }
コード例 #3
0
        public void Remove_AnnotationFromFile_RepositoryNotifiesIndices()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'><annotation guid='123'>
<message guid='234'>&lt;p&gt;hello</message></annotation></notes>"))
            {
                var index = new TestAnnotationIndex();
                r.AddObserver(index, _progress);
                var annotation = r.GetAllAnnotations().First();
                r.Remove(annotation);
                Assert.AreEqual(1, index.Deletions);
            }
        }
コード例 #4
0
 public void CloseAnnotation_AnnotationFromFile_RepositoryNotifiesIndices()
 {
     using (var r = AnnotationRepository.FromString("id", @"<notes version='0'><annotation guid='123'>
     <message guid='234'>&lt;p&gt;hello</message></annotation></notes>"))
     {
         var index = new TestAnnotationIndex();
         r.AddObserver(index, _progress);
         var annotation = r.GetAllAnnotations().First();
         annotation.SetStatus("joe", "closed");
         Assert.AreEqual(1, index.Modification);
     }
 }
コード例 #5
0
        public void AddAnnotation_NotifiesIndices()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'/>"))
            {
                var index = new TestAnnotationIndex();
                r.AddObserver(index, _progress);

                r.AddAnnotation(new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath"));
                r.AddAnnotation(new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath"));

                Assert.AreEqual(2, index.Additions);
                Assert.AreEqual(0, index.Modification);
            }
        }
コード例 #6
0
        public void AddAnnotation_NotifiesIndices()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'/>"))
            {
                var index = new TestAnnotationIndex();
                r.AddObserver(index, _progress);

                r.AddAnnotation(new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath"));
                r.AddAnnotation(new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath"));

                Assert.AreEqual(2, index.Additions);
                Assert.AreEqual(0, index.Modification);
            }
        }
コード例 #7
0
        public void Remove_AnnotationWasAddedDynamically_RepositoryNotifiesIndices()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'/>"))
            {
                var index = new TestAnnotationIndex();
                r.AddObserver(index, _progress);

                var annotation = new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath");
                r.AddAnnotation(annotation);

                Assert.AreEqual(0, index.Deletions);
                r.Remove(annotation);

                Assert.AreEqual(1, index.Deletions);
            }
        }
コード例 #8
0
        public void ExternalFileModification_NotifiesIndices_ButSaveDoesNot()
        {
            using (var t = new TempFile(@"<notes version='0'><annotation guid='123'>
<message guid='234'>&lt;p&gt;hello</message></annotation></notes>"))
            {
                using (var r = AnnotationRepository.FromFile("id", t.Path, new NullProgress()))
                {
                    var index = new TestAnnotationIndex();
                    r.AddObserver(index, _progress);

                    File.WriteAllText(t.Path, @"<notes version='0'><annotation guid='123'>
<message guid='234'>&lt;p&gt;goodbye</message></annotation></notes>");

                    int tries = 0;
                    while (index.StaleNotifications == 0 && tries++ < 3)
                    {
                        Thread.Sleep(10);
                    }
                    Assert.AreEqual(1, index.StaleNotifications);

                    var annotation = new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath");
                    r.AddAnnotation(annotation);

                    r.Save(new NullProgress());

                    tries = 0;
                    while (index.StaleNotifications == 1 && tries++ < 3)
                    {
                        Thread.Sleep(10);
                    }
                    // It's still 1, after waiting long enough to be fairly sure we would have
                    // seen the notification.
                    Assert.AreEqual(1, index.StaleNotifications);
                }
            }
        }
コード例 #9
0
        public void CloseAnnotation_AnnotationWasAddedDynamically_RepositoryNotifiesIndices()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'/>"))
            {
                var index = new TestAnnotationIndex();
                r.AddObserver(index, _progress);

                var annotation = new Annotation("question", "foo://blah.org?id=1", @"c:\pretendPath");
                r.AddAnnotation(annotation);

                Assert.AreEqual(0, index.Modification);
                annotation.SetStatus("joe", "closed");

                Assert.AreEqual(1, index.Modification);
            }
        }