Ejemplo n.º 1
0
        public void when_adding_annotation_then_can_retrieve_it()
        {
            var annotated = new AnnotatedObject();

            annotated.AddAnnotation(new FooAnnotation());

            Assert.NotNull(annotated.Annotation<FooAnnotation>());
        }
Ejemplo n.º 2
0
        public void when_adding_second_annotation_then_state_becomes_array()
        {
            var annotated = new AnnotatedObject();

            annotated.AddAnnotation(new FooAnnotation());
            annotated.AddAnnotation(new BarAnnotation());

            Assert.IsType<object[]>(annotated.AnnotationState);
        }
Ejemplo n.º 3
0
        public void when_adding_annotation_then_state_equals_annotation()
        {
            var annotated = new AnnotatedObject();
            var annotation = new FooAnnotation();

            annotated.AddAnnotation(annotation);

            Assert.Same(annotation, annotated.AnnotationState);
        }
Ejemplo n.º 4
0
        public void when_adding_two_annotations_of_same_type_then_can_retrieve_them()
        {
            var annotated = new AnnotatedObject();

            annotated.AddAnnotation(new FooAnnotation());
            annotated.AddAnnotation(new BarAnnotation());
            annotated.AddAnnotation(new FooAnnotation());

            var annotations = annotated.Annotations<FooAnnotation>().ToList();

            Assert.Equal(2, annotations.Count);
        }
Ejemplo n.º 5
0
        public void when_last_annotation_removed_then_sets_state_to_null()
        {
            var annotated = new AnnotatedObject();

            annotated.AddAnnotation(new FooAnnotation());
            annotated.AddAnnotation(new BarAnnotation());

            annotated.RemoveAnnotations<FooAnnotation>();
            annotated.RemoveAnnotations<BarAnnotation>();

            Assert.Null(annotated.AnnotationState);
        }
Ejemplo n.º 6
0
        public void when_adding_two_annotations_then_can_retrieve_one()
        {
            var annotated = new AnnotatedObject();
            var annotation = new FooAnnotation();

            annotated.AddAnnotation(annotation);
            annotated.AddAnnotation(new BarAnnotation());

            Assert.Same(annotation, annotated.Annotation<FooAnnotation>());
        }