Beispiel #1
0
        public void CreateMappingContext_creates_mapping_context()
        {
            var storeModel = new EdmModel(DataSpace.SSpace);

            var mappingContext =
                new ModelGenerator(new ModelBuilderSettings(), "storeNamespace")
                .CreateMappingContext(storeModel);

            Assert.NotNull(mappingContext);
            Assert.Same(storeModel, mappingContext.StoreModel);
        }
Beispiel #2
0
        public void CollectStoreModelErrors_returns_empty_error_list_for_model_without_errors()
        {
            var entityType =
                EntityType.Create("foo", "bar", DataSpace.SSpace, new string[0], new EdmMember[0], null);

            var model = new EdmModel(DataSpace.SSpace);

            model.AddItem(entityType);

            var schemaErrors = ModelGenerator.CollectStoreModelErrors(model);

            Assert.NotNull(schemaErrors);
            Assert.Empty(schemaErrors);
        }
Beispiel #3
0
        public void Mapping_context_created_with_CreateMappingContext_will_not_pluralize_if_pluralization_disabled()
        {
            var entityType = EntityType.Create("entities", "ns", DataSpace.SSpace, new string[0], new EdmMember[0], null);
            var entitySet  = EntitySet.Create("entitySet", "dbo", "t", null, entityType, null);
            var container  = EntityContainer.Create("container", DataSpace.SSpace, new[] { entitySet }, null, null);

            var storeModel = EdmModel.CreateStoreModel(container, null, null);

            var mappingContext =
                new ModelGenerator(new ModelBuilderSettings {
                UsePluralizationService = false
            }, "storeNamespace")
                .CreateMappingContext(storeModel);

            Assert.Equal("entities", mappingContext[entityType].Name);
            Assert.Equal("entitySet", mappingContext[entitySet].Name);
        }
Beispiel #4
0
        public void CollectStoreModelErrors_returns_errors_from_function_return_rowtypes()
        {
            var edmSchemaError        = new EdmSchemaError("msg", 42, EdmSchemaErrorSeverity.Error);
            var errorMetadataProperty =
                MetadataProperty.Create(
                    MetadataItemHelper.SchemaErrorsMetadataPropertyName,
                    TypeUsage.CreateDefaultTypeUsage(
                        PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String).GetCollectionType()),
                    new List <EdmSchemaError> {
                edmSchemaError
            });

            var rowType = RowType.Create(new EdmProperty[0], new[] { errorMetadataProperty });

            var function =
                EdmFunction.Create(
                    "foo",
                    "bar",
                    DataSpace.SSpace,
                    new EdmFunctionPayload
            {
                ReturnParameters =
                    new[]
                {
                    FunctionParameter.Create(
                        "ReturnType",
                        rowType,
                        ParameterMode.ReturnValue)
                }
            },
                    null);

            var model = new EdmModel(DataSpace.SSpace);

            model.AddItem(function);

            var schemaErrors = ModelGenerator.CollectStoreModelErrors(model);

            Assert.NotNull(schemaErrors);
            Assert.Equal(1, schemaErrors.Count);
            Assert.Same(edmSchemaError, schemaErrors.Single());
        }
        public void Mapping_context_created_with_CreateMappingContext_will_not_pluralize_if_pluralization_disabled()
        {
            var entityType = EntityType.Create("entities", "ns", DataSpace.SSpace, new string[0], new EdmMember[0], null);
            var entitySet = EntitySet.Create("entitySet", "dbo", "t", null, entityType, null);
            var container = EntityContainer.Create("container", DataSpace.SSpace, new[] { entitySet }, null, null);

            var storeModel = EdmModel.CreateStoreModel(container, null, null);

            var mappingContext =
                new ModelGenerator(new ModelBuilderSettings { UsePluralizationService = false }, "storeNamespace")
                    .CreateMappingContext(storeModel);

            Assert.Equal("entities", mappingContext[entityType].Name);
            Assert.Equal("entitySet", mappingContext[entitySet].Name);
        }
        public void CreateMappingContext_creates_mapping_context()
        {
            var storeModel = new EdmModel(DataSpace.SSpace);

            var mappingContext =
                new ModelGenerator(new ModelBuilderSettings(), "storeNamespace")
                    .CreateMappingContext(storeModel);

            Assert.NotNull(mappingContext);
            Assert.Same(storeModel, mappingContext.StoreModel);
        }