public void GetAnnotationTargetingNavigationProperty() { IEnumerable<DerivedET> annotationValue = null; DerivedET et = new DerivedET() { UserName = "******", ComplexP = new DerivedCT { Name = "DerivedCT", Description = "DerivedET Description" }, DerivedComplexP = new DerivedCT { Name = "DerivedCT1", Description = "DerivedET1 Description" }, NavP = new List<ET> { new DerivedET() { UserName = "******", ComplexP = new CT { Name = "DerivedCT" }, DerivedComplexP = new DerivedCT { Name = "DerivedCT1", Description = "DerivedET1 Description" }, NavP = null, }, new DerivedET() { UserName = "******", ComplexP = new CT { Name = "DerivedCT" }, NavP = new List<ET>() }, new DerivedET() { UserName = "******", ComplexP = new CT { Name = "DerivedCT" } }, new ET() { UserName = "******", ComplexP = new DerivedCT { Name = "DerivedCT", Description = "DerivedET Description" }, } } }; var result = dsc.TryGetAnnotation<Func<ICollection<ET>>, IEnumerable<DerivedET>>( () => et.NavP, NavOfDerivedETAnnotationTerm, out annotationValue); Assert.IsTrue(result); Assert.AreEqual(3, annotationValue.Count()); Assert.AreEqual("DerivedCT1", annotationValue.ElementAt(0).DerivedComplexP.Name); Assert.IsNull(annotationValue.ElementAt(0).NavP); Assert.AreEqual(0, annotationValue.ElementAt(1).NavP.Count); Assert.IsNull(annotationValue.ElementAt(2).DerivedComplexP); }
public void GetAnnotationTargetingPropertyInfo() { RecordAnnotationType annotationValue = null; DerivedET et = new DerivedET() { UserName = "******", ComplexP = new DerivedCT { Name = "DerivedCT", Description = "DerivedET Description" }, DerivedComplexP = new DerivedCT { Name = "DerivedCT1", Description = "DerivedET1 Description" } }; var result = dsc.TryGetAnnotation<Func<DerivedCT>, RecordAnnotationType>( () => et.DerivedComplexP, RecordAnnotation, out annotationValue); Assert.IsTrue(result); Assert.AreEqual("ET", annotationValue.Name); Assert.AreEqual(1, annotationValue.OtherProperties.Count); Assert.AreEqual("DerivedCT", annotationValue.OtherProperties.ElementAt(0)); Assert.AreEqual(1, annotationValue.CollectionOfCTP.Count); Assert.AreEqual("DerivedCT", annotationValue.CollectionOfCTP.ElementAt(0).Name); Assert.AreEqual(1, annotationValue.CollectionOfDerivedCTP.Count); var derivedCT = annotationValue.CollectionOfCTP.ElementAt(0) as DerivedCT; Assert.AreEqual("DerivedET Description", derivedCT.Description); }