public void DynamicDictionaryProperty_Works_ToSetOpenComplexType() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); // Act ComplexTypeConfiguration <SimpleOpenComplexType> complexType = builder.ComplexType <SimpleOpenComplexType>(); complexType.Property(c => c.IntProperty); complexType.HasDynamicProperties(c => c.DynamicProperties); // Act & Assert Assert.True(complexType.IsOpen); }
public void DerivesFrom_Throws_WhenSettingTheBaseType_IfDuplicatePropertyInBaseType() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); builder.ComplexType <BaseComplexType>().Property(v => v.BaseProperty); ComplexTypeConfiguration <DerivedComplexType> derivedComplex = builder.ComplexType <DerivedComplexType>(); derivedComplex.Property(m => m.BaseProperty); // Act & Assert Assert.ThrowsArgument( () => derivedComplex.DerivesFrom <BaseComplexType>(), "propertyInfo", "Cannot redefine property 'BaseProperty' already defined on the base type 'System.Web.OData.Builder.BaseComplexType'."); }
public void GetEdmModel_WorksOnModelBuilder_ForOpenComplexType() { // Arrange ODataModelBuilder builder = new ODataModelBuilder(); ComplexTypeConfiguration <SimpleOpenComplexType> complex = builder.ComplexType <SimpleOpenComplexType>(); complex.Property(c => c.IntProperty); complex.HasDynamicProperties(c => c.DynamicProperties); // Act IEdmModel model = builder.GetEdmModel(); // Assert Assert.NotNull(model); IEdmComplexType complexType = Assert.Single(model.SchemaElements.OfType <IEdmComplexType>()); Assert.True(complexType.IsOpen); IEdmProperty edmProperty = Assert.Single(complexType.Properties()); Assert.Equal("IntProperty", edmProperty.Name); }