Ejemplo n.º 1
0
        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.True(result);
            Assert.Equal("ET", annotationValue.Name);
            Assert.Equal(1, annotationValue.OtherProperties.Count);
            Assert.Equal("DerivedCT", annotationValue.OtherProperties.ElementAt(0));
            Assert.Equal(1, annotationValue.CollectionOfCTP.Count);
            Assert.Equal("DerivedCT", annotationValue.CollectionOfCTP.ElementAt(0).Name);
            Assert.Equal(1, annotationValue.CollectionOfDerivedCTP.Count);
            var derivedCT = annotationValue.CollectionOfCTP.ElementAt(0) as DerivedCT;

            Assert.Equal("DerivedET Description", derivedCT.Description);
        }
Ejemplo n.º 2
0
        public void GetAnnotationTargetingType()
        {
            RecordAnnotationType annotationValue = null;

            ET et = new ET()
            {
                UserName = "******", ComplexP = new CT {
                    Name = "CT"
                }
            };
            var result = dsc.TryGetAnnotation(
                et,
                RecordAnnotation,
                out annotationValue);

            Assert.True(result);
            Assert.Equal("ET", annotationValue.Name);
            Assert.Equal(1, annotationValue.OtherProperties.Count);
            Assert.Equal("CT", annotationValue.OtherProperties.ElementAt(0));
        }