public void Cannot_remove_property_when_read_only() { var associationEnd = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace)); var mapping = new EndPropertyMapping(associationEnd); var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace }))); mapping.AddProperty(scalarPropertyMapping); mapping.SetReadOnly(); Assert.True(mapping.IsReadOnly); Assert.Equal( Strings.OperationOnReadOnlyItem, Assert.Throws <InvalidOperationException>( () => mapping.RemoveProperty(scalarPropertyMapping)).Message); }
public void Can_add_get_remove_properties() { var endPropertyMapping = new EndPropertyMapping(); Assert.Empty(endPropertyMapping.Properties); var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace }))); endPropertyMapping.AddProperty(scalarPropertyMapping); Assert.Same(scalarPropertyMapping, endPropertyMapping.Properties.Single()); endPropertyMapping.RemoveProperty(scalarPropertyMapping); Assert.Empty(endPropertyMapping.Properties); }