public void Can_add_and_remove_column_conditions() { var mappingFragment = new MappingFragment( new EntitySet(), new EntityTypeMapping( new EntitySetMapping( new EntitySet(), new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false); Assert.Empty(mappingFragment.ColumnConditions); var conditionPropertyMapping = new ValueConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType { DataSpace = DataSpace.SSpace })), 42); mappingFragment.AddConditionProperty(conditionPropertyMapping); Assert.Same(conditionPropertyMapping, mappingFragment.ColumnConditions.Single()); mappingFragment.RemoveConditionProperty(conditionPropertyMapping); Assert.Empty(mappingFragment.ColumnConditions); }
public void Can_get_and_set_Value() { var conditionPropertyMapping = new ValueConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType { DataSpace = DataSpace.SSpace })), 42); Assert.Equal(42, conditionPropertyMapping.Value); Assert.Null(conditionPropertyMapping.IsNull); }
public void Can_create_value_condition_mapping_with_column() { var primitiveType = FakeSqlProviderServices.Instance.GetProviderManifest("2008").GetStoreTypes().First(); var column = EdmProperty.CreatePrimitive("C", primitiveType); var mapping = new ValueConditionMapping(column, 42); Assert.Same(column, mapping.Column); Assert.Null(mapping.Property); Assert.Equal(42, mapping.Value); Assert.Null(mapping.IsNull); }
public void Can_create_value_condition_mapping_with_property() { var primitiveType = PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String); var property = EdmProperty.CreatePrimitive("P", primitiveType); var mapping = new ValueConditionMapping(property, 42); Assert.Same(property, mapping.Property); Assert.Null(mapping.Column); Assert.Equal(42, mapping.Value); Assert.Null(mapping.IsNull); }
public void Can_get_and_set_column_property() { var column1 = new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })); var conditionPropertyMapping = new ValueConditionMapping(column1, 42); Assert.Same(column1, conditionPropertyMapping.Column); var column2 = new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })); conditionPropertyMapping.Column = column2; Assert.Same(column2, conditionPropertyMapping.Column); }
public void Cannot_add_condition_when_read_only() { var entitySet = new EntitySet(); var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)); var associationSetMapping = new AssociationSetMapping(associationSet, entitySet); var conditionPropertyMapping = new ValueConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType { DataSpace = DataSpace.SSpace })), 42); associationSetMapping.SetReadOnly(); Assert.Equal( Strings.OperationOnReadOnlyItem, Assert.Throws <InvalidOperationException>( () => associationSetMapping.AddCondition(conditionPropertyMapping)).Message); }
public static void GetIdentity_of_StorageConditionPropertyMapping_returns_expected_value() { var typeUsage = TypeUsage.Create(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)); var property1 = new EdmProperty("A", typeUsage); var property2 = new EdmProperty("B", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })); PropertyMapping mapping = new ValueConditionMapping(property1, "V"); Assert.Equal("ConditionProperty(Identity=A)", BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping)); mapping = new ValueConditionMapping(property2, "V"); Assert.Equal("ConditionProperty(ColumnIdentity=B)", BaseMetadataMappingVisitor.IdentityHelper.GetIdentity(mapping)); }
public void Can_add_get_remove_column_conditions() { var entitySet1 = new EntitySet(); var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)); var associationSetMapping = new AssociationSetMapping(associationSet, entitySet1); Assert.Empty(associationSetMapping.Conditions); var conditionPropertyMapping = new ValueConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType { DataSpace = DataSpace.SSpace })), 42); associationSetMapping.AddCondition(conditionPropertyMapping); Assert.Same(conditionPropertyMapping, associationSetMapping.Conditions.Single()); associationSetMapping.RemoveCondition(conditionPropertyMapping); Assert.Empty(associationSetMapping.Conditions); }
public void Cannot_remove_condition_when_read_only() { var entitySet = new EntitySet(); var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace)); var associationSetMapping = new AssociationSetMapping(associationSet, entitySet); var conditionPropertyMapping = new ValueConditionMapping(new EdmProperty("C", TypeUsage.Create(new PrimitiveType { DataSpace = DataSpace.SSpace })), 42); associationSetMapping.AddCondition(conditionPropertyMapping); associationSetMapping.SetReadOnly(); Assert.Equal( Strings.OperationOnReadOnlyItem, Assert.Throws<InvalidOperationException>( () => associationSetMapping.RemoveCondition(conditionPropertyMapping)).Message); }