public void GetAllProperties_Ignores_IndexerProperties()
        {
            Mock <IStructuralTypeConfiguration> edmType = new Mock <IStructuralTypeConfiguration>();

            edmType.Setup(t => t.ClrType).Returns(typeof(GetProperties_Derived));

            var properties = ConventionsHelpers.GetAllProperties(edmType.Object).Select(p => p.Name);

            Assert.DoesNotContain("Item", properties);
        }
        public void GetAllProperties_Returns_PropertiesOfNestedTypes()
        {
            Mock <IStructuralTypeConfiguration> edmType = new Mock <IStructuralTypeConfiguration>();

            edmType.Setup(t => t.ClrType).Returns(typeof(GetProperties_NestParent.Nest));

            var properties = ConventionsHelpers.GetAllProperties(edmType.Object).Select(p => p.Name);

            Assert.Equal(1, properties.Count());
            Assert.Equal("NestProperty", properties.First());
        }
        public void GetProperties_ReturnsProperties_FromBaseAndDerived()
        {
            Mock <IStructuralTypeConfiguration> edmType = new Mock <IStructuralTypeConfiguration>();

            edmType.Setup(t => t.ClrType).Returns(typeof(GetProperties_Derived));

            var properties         = ConventionsHelpers.GetAllProperties(edmType.Object);
            var expectedProperties = new string[] { "Base_I", "Base_Complex", "Base_Str", "Derived_I", "Derived_Complex", "Collection", "PrivateSetPublicGet" };

            Assert.Equal(expectedProperties.OrderByDescending(name => name), properties.Select(p => p.Name).OrderByDescending(name => name));
        }
Beispiel #4
0
        public void GetProperties_ExcludeReadOnlyProperties()
        {
            Mock <StructuralTypeConfiguration> edmType = new Mock <StructuralTypeConfiguration>();

            edmType.Setup(t => t.ClrType).Returns(typeof(GetProperties_Derived));

            var properties         = ConventionsHelpers.GetAllProperties(edmType.Object, includeReadOnly: false);
            var expectedProperties = new string[] { "Derived_I", "Derived_Complex", "Collection", "Base_Str", "Base_I", "Base_Complex" };

            Assert.Equal(expectedProperties.OrderByDescending(name => name), properties.Select(p => p.Name).OrderByDescending(name => name));
        }