public static void GetIdentity_of_StorageEntityTypeMapping_returns_expected_value()
        {
            var entityType1 = new EntityType("ET1", "N", DataSpace.CSpace);
            var entityType2 = new EntityType("ET2", "N", DataSpace.CSpace);
            var entityType3 = new EntityType("ET3", "N", DataSpace.CSpace);
            var entityType4 = new EntityType("ET4", "N", DataSpace.CSpace);
            var mapping     = new EntityTypeMapping(null);

            mapping.AddType(entityType2);
            mapping.AddType(entityType1);
            mapping.AddIsOfType(entityType4);
            mapping.AddIsOfType(entityType3);

            Assert.Equal("N.ET1,N.ET2,N.ET3,N.ET4",
                         BaseMetadataMappingVisitor.IdentityHelper.GetIdentity((TypeMapping)mapping));
        }
Exemplo n.º 2
0
        public void Can_create_hierarchy_mappings()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                      new EntitySetMapping(new EntitySet(), new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            Assert.False(entityTypeMapping.IsHierarchyMapping);

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityTypeMapping.AddIsOfType(entityType);

            Assert.True(entityTypeMapping.IsHierarchyMapping);

            entityTypeMapping.RemoveIsOfType(entityType);
            entityTypeMapping.AddType(entityType);

            Assert.False(entityTypeMapping.IsHierarchyMapping);

            var entityType2 = new EntityType("E2", "N", DataSpace.CSpace);

            entityTypeMapping.AddType(entityType2);

            Assert.True(entityTypeMapping.IsHierarchyMapping);
        }
Exemplo n.º 3
0
        public void Cannot_add_isOfType_when_read_only()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                      new EntitySetMapping(
                          new EntitySet(),
                          new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            entityTypeMapping.SetReadOnly();

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws <InvalidOperationException>(
                    () => entityTypeMapping.AddIsOfType(entityType)).Message);
        }
Exemplo n.º 4
0
        public void Added_isOfType_returned_in_isOfType_collection()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                      new EntitySetMapping(
                          new EntitySet(),
                          new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            Assert.Empty(entityTypeMapping.Types);
            Assert.Empty(entityTypeMapping.IsOfTypes);

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityTypeMapping.AddIsOfType(entityType);

            Assert.Same(entityType, entityTypeMapping.IsOfTypes.Single());
            Assert.Empty(entityTypeMapping.Types);
        }
Exemplo n.º 5
0
        public void Can_add_remove_isOfType()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                      new EntitySetMapping(
                          new EntitySet(),
                          new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            Assert.Empty(entityTypeMapping.IsOfTypes);

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityTypeMapping.AddIsOfType(entityType);

            Assert.Same(entityType, entityTypeMapping.IsOfTypes.Single());

            entityTypeMapping.RemoveIsOfType(entityType);

            Assert.Empty(entityTypeMapping.IsOfTypes);
        }
        public void Can_create_hierarchy_mappings()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                    new EntitySetMapping(new EntitySet(), new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            Assert.False(entityTypeMapping.IsHierarchyMapping);

            var entityType = new EntityType("E", "N", DataSpace.CSpace);
            
            entityTypeMapping.AddIsOfType(entityType);

            Assert.True(entityTypeMapping.IsHierarchyMapping);

            entityTypeMapping.RemoveIsOfType(entityType);
            entityTypeMapping.AddType(entityType);

            Assert.False(entityTypeMapping.IsHierarchyMapping);

            var entityType2 = new EntityType("E2", "N", DataSpace.CSpace);
            entityTypeMapping.AddType(entityType2);

            Assert.True(entityTypeMapping.IsHierarchyMapping);
        }
        public void Added_isOfType_returned_in_isOfType_collection()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                    new EntitySetMapping(
                        new EntitySet(),
                        new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            Assert.Empty(entityTypeMapping.Types);
            Assert.Empty(entityTypeMapping.IsOfTypes);

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityTypeMapping.AddIsOfType(entityType);

            Assert.Same(entityType, entityTypeMapping.IsOfTypes.Single());
            Assert.Empty(entityTypeMapping.Types);
        }
        public void Cannot_remove_isOfType_when_read_only()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                    new EntitySetMapping(
                        new EntitySet(),
                        new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityTypeMapping.AddIsOfType(entityType);

            entityTypeMapping.SetReadOnly();

            Assert.Equal(
                Strings.OperationOnReadOnlyItem,
                Assert.Throws<InvalidOperationException>(
                    () => entityTypeMapping.RemoveIsOfType(entityType)).Message);
        }
        public void Can_add_remove_isOfType()
        {
            var entityTypeMapping
                = new EntityTypeMapping(
                    new EntitySetMapping(
                        new EntitySet(),
                        new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace))));

            Assert.Empty(entityTypeMapping.IsOfTypes);

            var entityType = new EntityType("E", "N", DataSpace.CSpace);

            entityTypeMapping.AddIsOfType(entityType);

            Assert.Same(entityType, entityTypeMapping.IsOfTypes.Single());

            entityTypeMapping.RemoveIsOfType(entityType);

            Assert.Empty(entityTypeMapping.IsOfTypes);
        }
        public static void GetIdentity_of_StorageEntityTypeMapping_returns_expected_value()
        {
            var entityType1 = new EntityType("ET1", "N", DataSpace.CSpace);
            var entityType2 = new EntityType("ET2", "N", DataSpace.CSpace);
            var entityType3 = new EntityType("ET3", "N", DataSpace.CSpace);
            var entityType4 = new EntityType("ET4", "N", DataSpace.CSpace);
            var mapping = new EntityTypeMapping(null);
            mapping.AddType(entityType2);
            mapping.AddType(entityType1);
            mapping.AddIsOfType(entityType4);
            mapping.AddIsOfType(entityType3);

            Assert.Equal("N.ET1,N.ET2,N.ET3,N.ET4",
                BaseMetadataMappingVisitor.IdentityHelper.GetIdentity((TypeMapping)mapping));
        }