Ejemplo n.º 1
0
        public void SingletonAnnotationsTest()
        {
            TestAnnotatable annotatable = new TestAnnotatable();
            Annotation1     one         = new Annotation1();

            annotatable.SetAnnotation(one);

            Annotation1 retrievedOne = annotatable.GetAnnotation <Annotation1>();

            this.Assert.AreSame(one, retrievedOne,
                                "Expected retrieved annotation to be reference equal with set annotation.");

            Annotation1 anotherOne = new Annotation1();

            annotatable.SetAnnotation <Annotation1>(anotherOne);
            retrievedOne = annotatable.GetAnnotation <Annotation1>();
            this.Assert.AreSame(anotherOne, retrievedOne,
                                "Expected retrieved annotation to be reference equal with new annotation replacing original one.");

            Annotation2 retrievedTwo = annotatable.GetAnnotation <Annotation2>();

            this.Assert.IsNull(retrievedTwo, "Expected to not find an annotation of type Annotation2.");

            annotatable.SetAnnotation <Annotation2>(null);

            retrievedTwo = annotatable.GetAnnotation <Annotation2>();
            this.Assert.IsNull(retrievedTwo, "Expected to not find an annotation of type Annotation2.");

            annotatable.SetAnnotation <Annotation1>(null);
            retrievedOne = annotatable.GetAnnotation <Annotation1>();
            this.Assert.IsNull(retrievedOne, "Expected to not find an annotation of type Annotation1.");
        }
Ejemplo n.º 2
0
        public void MultipleAnnotationsTest()
        {
            // this triggers resizing the array (from 2 to 4 items) and filling it up to the last spot
            Annotation1 one   = new Annotation1();
            Annotation2 two   = new Annotation2();
            Annotation3 three = new Annotation3();
            Annotation4 four  = new Annotation4();

            TestAnnotatable annotatable = new TestAnnotatable();

            annotatable.SetAnnotation(one);
            annotatable.SetAnnotation(two);
            annotatable.SetAnnotation(three);
            annotatable.SetAnnotation(four);

            // TODO: ckerer: call the combination engine with an annotatable with 3 and 4 elements here!

            Annotation3 retrievedThree = annotatable.GetAnnotation <Annotation3>();

            this.Assert.AreSame(three, retrievedThree,
                                "Expected retrieved annotation to be reference equal with originally set one.");

            Annotation4 retrievedFour = annotatable.GetAnnotation <Annotation4>();

            this.Assert.AreSame(four, retrievedFour,
                                "Expected retrieved annotation to be reference equal with originally set one.");

            annotatable.SetAnnotation <Annotation3>(null);
            retrievedThree = annotatable.GetAnnotation <Annotation3>();
            this.Assert.IsNull(retrievedThree, "Expected to not find an annotation of type Annotation3.");

            retrievedFour = annotatable.GetAnnotation <Annotation4>();
            this.Assert.AreSame(four, retrievedFour,
                                "Expected retrieved annotation to be reference equal with originally set one.");

            annotatable.SetAnnotation <Annotation3>(null);
            retrievedThree = annotatable.GetAnnotation <Annotation3>();
            this.Assert.IsNull(retrievedThree, "Expected to not find an annotation of type Annotation3.");

            annotatable.SetAnnotation <Annotation4>(null);
            retrievedFour = annotatable.GetAnnotation <Annotation4>();
            this.Assert.IsNull(retrievedFour, "Expected to not find an annotation of type Annotation4.");
        }
Ejemplo n.º 3
0
        public void MultipleAnnotationsTest()
        {
            // this triggers resizing the array (from 2 to 4 items) and filling it up to the last spot
            Annotation1 one = new Annotation1();
            Annotation2 two = new Annotation2();
            Annotation3 three = new Annotation3();
            Annotation4 four = new Annotation4();

            TestAnnotatable annotatable = new TestAnnotatable();
            annotatable.SetAnnotation(one);
            annotatable.SetAnnotation(two);
            annotatable.SetAnnotation(three);
            annotatable.SetAnnotation(four);

            // TODO: ckerer: call the combination engine with an annotatable with 3 and 4 elements here!

            Annotation3 retrievedThree = annotatable.GetAnnotation<Annotation3>();
            this.Assert.AreSame(three, retrievedThree,
                "Expected retrieved annotation to be reference equal with originally set one.");

            Annotation4 retrievedFour = annotatable.GetAnnotation<Annotation4>();
            this.Assert.AreSame(four, retrievedFour,
                "Expected retrieved annotation to be reference equal with originally set one.");

            annotatable.SetAnnotation<Annotation3>(null);
            retrievedThree = annotatable.GetAnnotation<Annotation3>();
            this.Assert.IsNull(retrievedThree, "Expected to not find an annotation of type Annotation3.");

            retrievedFour = annotatable.GetAnnotation<Annotation4>();
            this.Assert.AreSame(four, retrievedFour,
                "Expected retrieved annotation to be reference equal with originally set one.");

            annotatable.SetAnnotation<Annotation3>(null);
            retrievedThree = annotatable.GetAnnotation<Annotation3>();
            this.Assert.IsNull(retrievedThree, "Expected to not find an annotation of type Annotation3.");

            annotatable.SetAnnotation<Annotation4>(null);
            retrievedFour = annotatable.GetAnnotation<Annotation4>();
            this.Assert.IsNull(retrievedFour, "Expected to not find an annotation of type Annotation4.");
        }
        public void CheckAnnotation()
        {
            var a = Annotation1.Create();

            a.ID = 23;
            a.SetIDD(18);
            var a2 = Serializer.Clone(a);

            Assert.Equal(0, a2.ID);
            Assert.Equal(18, a2.GetIDD());

            var b = new Annotation2
            {
                ID1 = 1,
                ID2 = 2,
            };

            b.SetID3(3);
            var b2 = Serializer.Clone(b);

            Assert.Equal(1, b2.ID1); // ahem property automatically saved with private backing field... not sure what to do about that....
            Assert.Equal(2, b2.ID2);
            Assert.Equal(3, b2.GetID3());

            var c = new Annotation3
            {
                ID1 = 1,
                ID2 = 2,
            };

            c.SetID3(3);
            var c2 = Serializer.Clone(c);

            Assert.Equal(0, c2.ID1);
            Assert.Equal(2, c2.ID2);
            Assert.Equal(0, c2.GetID3());
        }