Esempio n. 1
0
        public void AddAnnotations(Annotation[] annotations)
        {
            if (annotations == null)
                throw new ModelException($"{nameof(annotations)} must not be null");

            this.loadedAnnotations.AddRange(annotations);
        }
 public AnnotationsController()
 {
     //TODO Remove - this was just to test output when hitting API
     Annotation a = new Annotation();
     annotationManager = new AnnotationManager();
     annotationManager.AddAnnotation(a);
 }
Esempio n. 3
0
        public void AddAnnotation(Annotation newAnnotation)
        {
            if (newAnnotation == null)
                throw new ModelException($"{nameof(newAnnotation)} must not be null");

            this.loadedAnnotations.Add(newAnnotation);
        }
Esempio n. 4
0
 public bool TryGetAnnotationAt(int index, out Annotation annotation)
 {
     if (loadedAnnotations.Count > index)
     {
         annotation = this.loadedAnnotations.ElementAt<Annotation>(index);
         return true;
     }
     annotation = null;
     return false;
 }
        public void TestAddAnnotation()
        {
            Annotation anno1 = new Annotation();
            Annotation anno2 = new Annotation();

            this.annotationManager.AddAnnotation(anno1);
            this.annotationManager.AddAnnotation(anno2);

            Assert.IsTrue(testAnnotationList.Contains(anno1), "List does not contain expected annotation.");
            Assert.IsTrue(testAnnotationList.Contains(anno2), "List does not contain expected annotation.");
        }
        public void TestGetAllAnnotations()
        {
            Annotation anno1 = new Annotation();
            Annotation anno2 = new Annotation();
            Annotation anno3 = new Annotation();
            Annotation[] expectedAnnotations = new Annotation[] { anno1, anno2, anno3 };

            this.annotationManager.AddAnnotations(expectedAnnotations);

            Annotation[] resultAnnotations = this.annotationManager.GetAllAnnotations();

            Assert.IsTrue(resultAnnotations.SequenceEqual(expectedAnnotations), "Returned annotations should be the same.");
        }
        public void TestTryGetAnnotationAt()
        {
            Annotation anno1 = new Annotation();
            Annotation anno2 = new Annotation();
            Annotation anno3 = new Annotation();

            this.annotationManager.AddAnnotations(new Annotation[]{anno1, anno2, anno3});

            Annotation result1;
            bool returnResult1 = this.annotationManager.TryGetAnnotationAt(0, out result1);
            Annotation result2;
            bool returnResult2 = this.annotationManager.TryGetAnnotationAt(2, out result2);

            Assert.AreSame(anno1, result1, "Returned object should be same as expected.");
            Assert.AreSame(anno3, result2, "Returned object should be same as expected.");
            Assert.IsTrue(returnResult1, "Should have returned as true.");
            Assert.IsTrue(returnResult2, "Should have returned as true.");
        }
Esempio n. 8
0
 public AnnotationManager(Annotation[] annotations)
 {
     this.loadedAnnotations = new List<Annotation>();
     this.loadedAnnotations.AddRange(annotations);
 }
        public void TestTryGetAnnotationAt___OutOfIndex_ReturnFalse()
        {
            Annotation anno1 = new Annotation();
            Annotation anno2 = new Annotation();
            Annotation anno3 = new Annotation();

            this.annotationManager.AddAnnotations(new Annotation[] { anno1, anno2, anno3 });

            Annotation result1;
            bool returnResult1 = this.annotationManager.TryGetAnnotationAt(4, out result1);

            Assert.IsFalse(returnResult1, "Should have returned as false.");
        }