public static IMemberMetadataBuilder Property <TEntity>(
            this ITypeMetadataBuilder <TEntity> typeMetadataBuilder,
            Expression <Func <TEntity, object> > propertyExpression)
        {
            var propertyInfo = GetPropertyInfo(propertyExpression);

            return(typeMetadataBuilder.Property(propertyInfo.Name));
        }
        public static ITypeMetadataBuilder <TEntity> HasNonEditable <TEntity>(
            this ITypeMetadataBuilder <TEntity> typeMetadataBuilder,
            Expression <Func <TEntity, object> > propertyExpression)
        {
            var propertyInfo = GetPropertyInfo(propertyExpression);

            typeMetadataBuilder.Property(propertyInfo.Name).NonEditable();
            return(typeMetadataBuilder);
        }
        public void Entity_OnPersonType_ShouldReturnTypeBuilder()
        {
            // Arrange
            TypeCache        typeCache = new TypeCache();
            IMetadataBuilder builder   = new MetadataBuilder(typeCache);

            // Act
            ITypeMetadataBuilder <Person> entityBuilder = builder.Entity <Person>();

            // Assert
            Assert.NotNull(entityBuilder);
        }
        public void HasRequired_OnFirstNameProperty_ShouldReturnTypeBuilder()
        {
            // Arrange
            TypeCache   typeCache = new TypeCache();
            TypeContext context   = new TypeContext(typeof(Person).GetTypeInfo());
            ITypeMetadataBuilder <Person> builder =
                new TypeMetadataBuilderWrapper <Person>(
                    new TypeMetadataBuilder(context, typeCache));

            // Act
            ITypeMetadataBuilder <Person> entityBuilder = builder.HasRequired(p => p.FirstName);

            // Assert
            Assert.NotNull(entityBuilder);
        }
        public void Build_OnPersonType_ShouldReturnPersonAndPositionMetadata()
        {
            // Arrange
            TypeCache        typeCache = new TypeCache();
            IMetadataBuilder builder   = new MetadataBuilder(typeCache);

            // Act
            ITypeMetadataBuilder <Person> typeBuilder = builder.Entity <Person>();
            Metadata metadata = builder.Build();

            // Assert
            Assert.NotNull(metadata);
            Assert.NotNull(metadata.Types);
            Assert.NotEmpty(metadata.Types);
            Assert.True(metadata.Types.Any(x => x.TypeName == typeof(Person).Name));
            Assert.True(metadata.Types.Any(x => x.TypeName == typeof(Position).Name));
        }
Ejemplo n.º 6
0
 public TypeMetadataBuilderWrapper(ITypeMetadataBuilder metadataBuilder) => _metadataBuilder = metadataBuilder;