Exemplo n.º 1
0
        public void DynamicDictionaryProperty_Works_ToSetEntityTypeAsOpen()
        {
            // Arrange
            ODataModelBuilder builder = new ODataModelBuilder();

            // Act
            EntityTypeConfiguration <SimpleOpenEntityType> entityType = builder.EntityType <SimpleOpenEntityType>();

            entityType.HasKey(c => c.Id);
            entityType.Property(c => c.Name);
            entityType.HasDynamicProperties(c => c.DynamicProperties);

            // Act & Assert
            Assert.True(entityType.IsOpen);
        }
Exemplo n.º 2
0
        public void GetEdmModel_WorksOnModelBuilder_ForOpenEntityType()
        {
            // Arrange
            ODataModelBuilder builder = new ODataModelBuilder();
            EntityTypeConfiguration <SimpleOpenEntityType> entity = builder.EntityType <SimpleOpenEntityType>();

            entity.HasKey(c => c.Id);
            entity.Property(c => c.Name);
            entity.HasDynamicProperties(c => c.DynamicProperties);

            // Act
            IEdmModel model = builder.GetEdmModel();

            // Assert
            Assert.NotNull(model);
            IEdmEntityType entityType = Assert.Single(model.SchemaElements.OfType <IEdmEntityType>());

            Assert.True(entityType.IsOpen);
            Assert.Equal(2, entityType.Properties().Count());

            Assert.True(entityType.Properties().Where(c => c.Name == "Id").Any());
            Assert.True(entityType.Properties().Where(c => c.Name == "Name").Any());
        }