public void Can_add_and_remove_properties()
        {
            var mappingFragment
                = new MappingFragment(
                      new EntitySet(),
                      new EntityTypeMapping(
                          new EntitySetMapping(
                              new EntitySet(),
                              new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);

            Assert.Empty(mappingFragment.PropertyMappings);

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

            mappingFragment.AddPropertyMapping(scalarPropertyMapping);

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

            mappingFragment.RemovePropertyMapping(scalarPropertyMapping);

            Assert.Empty(mappingFragment.PropertyMappings);
        }
        public void Cannot_remove_property_when_read_only()
        {
            var mappingFragment
                = new MappingFragment(
                      new EntitySet(),
                      new EntityTypeMapping(
                          new EntitySetMapping(
                              new EntitySet(),
                              new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);
            var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType()
            {
                DataSpace = DataSpace.SSpace
            })));

            mappingFragment.AddPropertyMapping(scalarPropertyMapping);

            mappingFragment.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => mappingFragment.RemovePropertyMapping(scalarPropertyMapping)).Message);
        }
Ejemplo n.º 3
0
        public void Can_add_and_remove_properties()
        {
            var mappingFragment
                = new MappingFragment(
                    new EntitySet(),
                    new EntityTypeMapping(
                        new EntitySetMapping(
                            new EntitySet(),
                            new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);

            Assert.Empty(mappingFragment.PropertyMappings);

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

            mappingFragment.AddPropertyMapping(scalarPropertyMapping);

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

            mappingFragment.RemovePropertyMapping(scalarPropertyMapping);

            Assert.Empty(mappingFragment.PropertyMappings);
        }
Ejemplo n.º 4
0
        public void Cannot_remove_property_when_read_only()
        {
            var mappingFragment
                = new MappingFragment(
                    new EntitySet(),
                    new EntityTypeMapping(
                        new EntitySetMapping(
                            new EntitySet(),
                            new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace)))), false);
            var scalarPropertyMapping = new ScalarPropertyMapping(new EdmProperty("P"), new EdmProperty("C", TypeUsage.Create(new PrimitiveType() { DataSpace = DataSpace.SSpace })));

            mappingFragment.AddPropertyMapping(scalarPropertyMapping);

            mappingFragment.SetReadOnly();

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