public void Cannot_set_target_end_mapping_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 targetEndMapping = new EndPropertyMapping();

            associationSetMapping.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => (associationSetMapping.TargetEndMapping = targetEndMapping)).Message);
        }
        public void Cannot_set__modification_function_mapping_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 modificationFunctionMapping = new AssociationSetModificationFunctionMapping(associationSet, null, null);

            associationSetMapping.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => (associationSetMapping.ModificationFunctionMapping = modificationFunctionMapping)).Message);
        }
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var entityType                  = new EntityType("ET", "N", DataSpace.SSpace);
            var entitySet                   = new EntitySet("ES", "S", "T", "Q", entityType);
            var associationSet              = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace));
            var associationSetMapping       = new AssociationSetMapping(associationSet, entitySet, null);
            var modificationFunctionMapping = new AssociationSetModificationFunctionMapping(associationSet, null, null);

            associationSetMapping.ModificationFunctionMapping = modificationFunctionMapping;

            Assert.False(associationSetMapping.AssociationTypeMapping.IsReadOnly);
            Assert.False(modificationFunctionMapping.IsReadOnly);
            associationSetMapping.SetReadOnly();
            Assert.True(associationSetMapping.AssociationTypeMapping.IsReadOnly);
            Assert.True(modificationFunctionMapping.IsReadOnly);
        }
        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 void SetReadOnly_is_called_on_child_mapping_items()
        {
            var entityType = new EntityType("ET", "N", DataSpace.SSpace);
            var entitySet = new EntitySet("ES", "S", "T", "Q", entityType);
            var associationSet = new AssociationSet("AS", new AssociationType("A", XmlConstants.ModelNamespace_3, false, DataSpace.CSpace));
            var associationSetMapping = new AssociationSetMapping(associationSet, entitySet, null);
            var modificationFunctionMapping = new AssociationSetModificationFunctionMapping(associationSet, null, null);

            associationSetMapping.ModificationFunctionMapping = modificationFunctionMapping;

            Assert.False(associationSetMapping.AssociationTypeMapping.IsReadOnly);
            Assert.False(modificationFunctionMapping.IsReadOnly);
            associationSetMapping.SetReadOnly();
            Assert.True(associationSetMapping.AssociationTypeMapping.IsReadOnly);
            Assert.True(modificationFunctionMapping.IsReadOnly);
        }
        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 ConditionPropertyMapping(null, new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })), 42, null);

            associationSetMapping.AddCondition(conditionPropertyMapping);
            associationSetMapping.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => associationSetMapping.RemoveCondition(conditionPropertyMapping)).Message);
        }
        public void Cannot_set__modification_function_mapping_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 modificationFunctionMapping = new AssociationSetModificationFunctionMapping(associationSet, null, null);

            associationSetMapping.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => (associationSetMapping.ModificationFunctionMapping = modificationFunctionMapping)).Message);
        }
        public void Cannot_set_target_end_mapping_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 targetEndMapping = new EndPropertyMapping();

            associationSetMapping.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => (associationSetMapping.TargetEndMapping = targetEndMapping)).Message);
        }