public void Can_add_get_remove_properties()
        {
            var endPropertyMapping = new EndPropertyMapping();

            Assert.Empty(endPropertyMapping.PropertyMappings);

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

            endPropertyMapping.AddPropertyMapping(scalarPropertyMapping);

            Assert.Same(scalarPropertyMapping, endPropertyMapping.PropertyMappings.Single());

            endPropertyMapping.RemovePropertyMapping(scalarPropertyMapping);

            Assert.Empty(endPropertyMapping.PropertyMappings);
        }
        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.AddPropertyMapping(scalarPropertyMapping);
            mapping.SetReadOnly();

            Assert.True(mapping.IsReadOnly);

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => mapping.RemovePropertyMapping(scalarPropertyMapping)).Message);
        }
        public void Can_add_get_remove_properties()
        {
            var endPropertyMapping = new EndPropertyMapping();

            Assert.Empty(endPropertyMapping.PropertyMappings);

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

            endPropertyMapping.AddPropertyMapping(scalarPropertyMapping);

            Assert.Same(scalarPropertyMapping, endPropertyMapping.PropertyMappings.Single());

            endPropertyMapping.RemovePropertyMapping(scalarPropertyMapping);

            Assert.Empty(endPropertyMapping.PropertyMappings);
        }
        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.AddPropertyMapping(scalarPropertyMapping);
            mapping.SetReadOnly();

            Assert.True(mapping.IsReadOnly);

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => mapping.RemovePropertyMapping(scalarPropertyMapping)).Message);
        }