Пример #1
0
        public void SaveAndLoad_10KRecords_CompletesQuickly()
        {
            using (var f = new TempFile("<notes version='0'/>"))
            {
                Console.WriteLine("Building File...");
                var r = AnnotationRepository.FromFile("id", f.Path, new NullProgress());
                for (int i = 0; i < 10000; i++)
                {
                    var annotation = new Annotation("question", string.Format("nowhere://blah?id={0}", Guid.NewGuid().ToString()), f.Path);
                    r.AddAnnotation(annotation);
                    annotation.AddMessage("test", "open", "blah blah");
                }
                Console.WriteLine("Saving Large File...");
                var w = new System.Diagnostics.Stopwatch();
                w.Start();
                r.Save(new NullProgress());
                w.Stop();
                Console.WriteLine("Elapsed Time:" + w.ElapsedMilliseconds.ToString() + " milliseconds");
                Assert.IsTrue(w.ElapsedMilliseconds < 250);                 //it's around 70 on my laptop, and around 225 on mono desktop

                w.Reset();
                Console.WriteLine("Reading Large File...");
                w.Start();
                var rToRead = AnnotationRepository.FromFile("id", f.Path, new NullProgress());
                w.Stop();
                Console.WriteLine("Elapsed Time:" + w.ElapsedMilliseconds.ToString() + " milliseconds");
                Assert.IsTrue(w.ElapsedMilliseconds < 1000);                 //it's around 240 on my laptop, and around 800 on mono desktop
            }
        }
Пример #2
0
 /// <summary>
 /// Inverts whether the annotation is resolved or unresolved, adding the message text supplied
 /// </summary>
 /// <param name="newMessageText"></param>
 public void UnResolveAndAddMessage(string newMessageText)
 {
     Annotation.AddMessage(_user.Name,
                           IsResolved ? Annotation.Open : Annotation.Closed, // Invert the status
                           newMessageText);
     UpdateContentNow();
 }
Пример #3
0
        public void AddMessage_Had0_Has1()
        {
            var a = new Annotation(XElement.Parse(@"<annotation ref='pretend' class='foo' guid='123'>
			</annotation>"            ));
            var m = a.AddMessage("joe", "closed", string.Empty);

            Assert.AreEqual(1, a.Messages.Count());
        }
Пример #4
0
        public void AddMessage_Had1_Has2InCorrectOrder()
        {
            var a = new Annotation(XElement.Parse(@"<annotation ref='pretend' class='foo' guid='123'>
			<message guid='123' status='open'/></annotation>"            ));

            var m = a.AddMessage("joe", "closed", string.Empty);

            Assert.AreEqual(2, a.Messages.Count());
            Assert.AreEqual("open", a.Messages.First().Status);
            Assert.AreEqual("closed", a.Messages.ToArray()[1].Status);
        }
Пример #5
0
        public void GetMatches_AddedBeforeIndexInitialization_FoundViaPredicate()
        {
            using (var r = AnnotationRepository.FromString("id", @"<notes version='0'></notes>"))
            {
                var ann = new Annotation("conflict", "blah://blah?rid=12345", "somepath");
                ann.AddMessage("merger", "open", string.Empty);
                r.AddAnnotation(ann);

                var index = new IndexOfAllOpenConflicts();
                r.AddObserver(index, _progress);
                Assert.AreEqual(1, index.GetMatches(rf => rf.Contains("rid=12345"), _progress).Count());
                Assert.AreEqual(0, index.GetMatches(rf => rf.Contains("rid=333"), _progress).Count());
                ann.SetStatusToClosed("testman");
                Assert.AreEqual(0, index.GetMatches(rf => rf.Contains("rid=12345"), _progress).Count());
            }
        }
Пример #6
0
        public void ShowNotesBrowser_LargeNumber()
        {
            using (var f = new TempFile("<notes version='0'/>"))
            {
                var r = AnnotationRepository.FromFile("id", f.Path, new NullProgress());
                for (int i = 0; i < 10000; i++)
                {
                    var annotation = new Annotation("question",
                                                    string.Format("nowhere://blah?id={0}&label={1}", Guid.NewGuid().ToString(), i.ToString()),
                                                    f.Path);
                    r.AddAnnotation(annotation);
                    annotation.AddMessage("test", "open", "blah blah");
                }

                ShowBrowser(new List <AnnotationRepository> {
                    r
                });
            }
        }
Пример #7
0
 public void AddMessage(string newMessageText)
 {
     _annotation.AddMessage(_user.Name, null, newMessageText);
     UpdateContentNow();
 }