public void Cannot_add_property_when_read_only()
        {
            var associationEnd = new AssociationEndMember("E", new EntityType("E", "N", DataSpace.CSpace));
            var mapping = new EndPropertyMapping(associationEnd);
            mapping.SetReadOnly();

            Assert.True(mapping.IsReadOnly);

            var scalarPropertyMapping
                = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })));

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => mapping.AddPropertyMapping(scalarPropertyMapping)).Message);
        }
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            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);

            Assert.False(scalarPropertyMapping.IsReadOnly);
            mapping.SetReadOnly();
            Assert.True(scalarPropertyMapping.IsReadOnly);
        }
        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 SetReadOnly_is_called_on_child_mapping_items()
        {
            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.AddPropertyMapping(scalarPropertyMapping);

            Assert.False(scalarPropertyMapping.IsReadOnly);
            mapping.SetReadOnly();
            Assert.True(scalarPropertyMapping.IsReadOnly);
        }