예제 #1
0
        public void CreateOrphanAnnotation_DoesNotAddToRepository()
        {
            var repo  = AnnotationRepository.FromString("id", "<notes version='0'/>");
            var model = new NotesBarModel(repo);

            model.SetTargetObject("foo3");
            model.CreateAnnotation();
            Assert.AreEqual(0, repo.GetAllAnnotations().Count());
        }
예제 #2
0
        public void CreateAnnotation_CreatesNewAnotationUsingIdOfCurrentAnnotatedObject()
        {
            var repo  = AnnotationRepository.FromString("id", "<notes version='0'/>");
            var model = new NotesBarModel(repo);

            model.SetTargetObject("foo3");
            model.AddAnnotation(model.CreateAnnotation());
            Assert.AreEqual(1, repo.GetAllAnnotations().Count());
            Assert.IsTrue(repo.GetAllAnnotations().First().RefStillEscaped.Contains("id=" + "foo3"));
        }
예제 #3
0
        public void CreateAnnotation_HaveCustomUrlGenerator_UseIt()
        {
            var repo    = AnnotationRepository.FromString("id", "<notes version='0'/>");
            var mapping = new NotesToRecordMapping();

            mapping.FunctionToGoFromObjectToItsId      = (target) => "x" + target.ToString() + "x";
            mapping.FunctionToGetCurrentUrlForNewNotes = (unusedTarget, escapedId) => "foobar:" + escapedId;
            var model = new NotesBarModel(repo, mapping);

            model.SetTargetObject("foo3");
            model.AddAnnotation(model.CreateAnnotation());
            Assert.AreEqual(1, repo.GetAllAnnotations().Count());
            Assert.AreEqual("foobar:xfoo3x", repo.GetAllAnnotations().First().RefStillEscaped);
        }
예제 #4
0
        public void CreateAnnotation_KeyHasDangerousCharacters_ResultingUrlHasThemEscaped()
        {
            var repo    = AnnotationRepository.FromString("id", "<notes version='0'/>");
            var mapping = new NotesToRecordMapping();

            mapping.FunctionToGetCurrentUrlForNewNotes = (unusedTarget, escapedId) => string.Format("lift://object?type=entry&id={0}&type=test", escapedId);
            mapping.FunctionToGoFromObjectToItsId      = NotesToRecordMapping.DefaultIdGeneratorUsingObjectToStringAsId;

            //mapping.UrlGenerator = (target,key)=> string.Format("lift://object?type=entry&amp;id={0}&amp;type=test", key);
            var model = new NotesBarModel(repo, mapping);

            model.SetTargetObject("two'<three&four");
            model.AddAnnotation(model.CreateAnnotation());
            Assert.IsTrue(repo.GetAllAnnotations().First().RefUnEscaped.Contains("two'<three&four"));
        }