public void PolymorphicAnnotationsTest() { Annotation3 three = new Annotation3(); Annotation3Subtype threeSub = new Annotation3Subtype(); TestAnnotatable annotatable = new TestAnnotatable(); annotatable.SetAnnotation(three); annotatable.SetAnnotation(threeSub); // TODO: ckerer: call the combination engine with an annotatable where the entries are reversed! Annotation3 retrievedThree = annotatable.GetAnnotation <Annotation3>(); this.Assert.AreSame(three, retrievedThree, "Expected retrieved annotation to be reference equal with originally set one."); Annotation3Subtype retrievedThreeSub = annotatable.GetAnnotation <Annotation3Subtype>(); this.Assert.AreSame(threeSub, retrievedThreeSub, "Expected retrieved annotation to be reference equal with originally set one."); annotatable.SetAnnotation <Annotation3Subtype>(null); retrievedThreeSub = annotatable.GetAnnotation <Annotation3Subtype>(); this.Assert.IsNull(retrievedThreeSub, "Expected to not find an annotation of type Annotation3Subtype."); retrievedThree = annotatable.GetAnnotation <Annotation3>(); this.Assert.AreSame(three, retrievedThree, "Expected retrieved annotation to be reference equal with originally set one."); annotatable.SetAnnotation <Annotation3>(null); retrievedThree = annotatable.GetAnnotation <Annotation3>(); this.Assert.IsNull(retrievedThreeSub, "Expected to not find an annotation of type Annotation3Subtype."); }
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 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()); }
public void PolymorphicAnnotationsTest() { Annotation3 three = new Annotation3(); Annotation3Subtype threeSub = new Annotation3Subtype(); TestAnnotatable annotatable = new TestAnnotatable(); annotatable.SetAnnotation(three); annotatable.SetAnnotation(threeSub); // TODO: ckerer: call the combination engine with an annotatable where the entries are reversed! Annotation3 retrievedThree = annotatable.GetAnnotation<Annotation3>(); this.Assert.AreSame(three, retrievedThree, "Expected retrieved annotation to be reference equal with originally set one."); Annotation3Subtype retrievedThreeSub = annotatable.GetAnnotation<Annotation3Subtype>(); this.Assert.AreSame(threeSub, retrievedThreeSub, "Expected retrieved annotation to be reference equal with originally set one."); annotatable.SetAnnotation<Annotation3Subtype>(null); retrievedThreeSub = annotatable.GetAnnotation<Annotation3Subtype>(); this.Assert.IsNull(retrievedThreeSub, "Expected to not find an annotation of type Annotation3Subtype."); retrievedThree = annotatable.GetAnnotation<Annotation3>(); this.Assert.AreSame(three, retrievedThree, "Expected retrieved annotation to be reference equal with originally set one."); annotatable.SetAnnotation<Annotation3>(null); retrievedThree = annotatable.GetAnnotation<Annotation3>(); this.Assert.IsNull(retrievedThreeSub, "Expected to not find an annotation of type Annotation3Subtype."); }