Example #1
0
        public void Can_add_and_get_function_import_mapping()
        {
            var typeUsage =
                TypeUsage.CreateDefaultTypeUsage(
                    PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32).GetCollectionType());

            var entityContainerMapping = new EntityContainerMapping(new EntityContainer("C", DataSpace.CSpace));

            var composableFunctionMapping =
                new FunctionImportMappingComposable(
                    new EdmFunction(
                        "f", "model", DataSpace.CSpace,
                        new EdmFunctionPayload()
            {
                IsComposable     = true,
                ReturnParameters =
                    new[]
                {
                    new FunctionParameter(
                        "ReturnType",
                        typeUsage,
                        ParameterMode.ReturnValue),
                }
            }),
                    new EdmFunction(
                        "f", "store", DataSpace.SSpace,
                        new EdmFunctionPayload()
            {
                IsComposable     = true,
                ReturnParameters =
                    new[]
                {
                    new FunctionParameter(
                        "ReturnType",
                        typeUsage,
                        ParameterMode.ReturnValue),
                }
            }),
                    null);

            Assert.Empty(entityContainerMapping.FunctionImportMappings);
            entityContainerMapping.AddFunctionImportMapping(composableFunctionMapping);
            Assert.Same(composableFunctionMapping, entityContainerMapping.FunctionImportMappings.Single());
        }
Example #2
0
        public void SetReadOnly_is_called_on_child_mapping_items()
        {
            var conceptualContainer = new EntityContainer("C", DataSpace.CSpace);
            var storeContainer      = new EntityContainer("S", DataSpace.CSpace);
            var containerMapping    = new EntityContainerMapping(conceptualContainer, storeContainer, null, false);

            var entitySet
                = new EntitySet(
                      "ES", "S", "T", "Q",
                      new EntityType("ET", "N", DataSpace.SSpace));
            var entitySetMapping = new EntitySetMapping(entitySet, containerMapping);
            var associationSetMapping
                = new AssociationSetMapping(
                      new AssociationSet(
                          "AS",
                          new AssociationType("AT", "N", false, DataSpace.CSpace)),
                      entitySet);
            var functionImportMapping
                = new FunctionImportMappingFake(
                      new EdmFunction("FI", "N", DataSpace.CSpace),
                      new EdmFunction("TF", "N", DataSpace.SSpace));

            containerMapping.AddSetMapping(entitySetMapping);
            containerMapping.AddSetMapping(associationSetMapping);
            containerMapping.AddFunctionImportMapping(functionImportMapping);

            Assert.False(containerMapping.IsReadOnly);
            Assert.False(entitySetMapping.IsReadOnly);
            Assert.False(associationSetMapping.IsReadOnly);
            Assert.False(functionImportMapping.IsReadOnly);

            containerMapping.SetReadOnly();

            Assert.True(containerMapping.IsReadOnly);
            Assert.True(entitySetMapping.IsReadOnly);
            Assert.True(associationSetMapping.IsReadOnly);
            Assert.True(functionImportMapping.IsReadOnly);
        }