Ejemplo n.º 1
0
        public void Cannot_create_EntityContainer_with_function_not_marked_as_function_import()
        {
            var function = new EdmFunction(
                "foo",
                "bar",
                DataSpace.CSpace,
                new EdmFunctionPayload()
            {
                IsFunctionImport = false
            });

            Assert.Equal(
                Resources.Strings.OnlyFunctionImportsCanBeAddedToEntityContainer("foo"),
                Assert.Throws <ArgumentException>(
                    () =>
                    EntityContainer.Create("Foo", DataSpace.SSpace, null, new[] { function }, null)).Message);
        }
Ejemplo n.º 2
0
        public void Create_factory_method_sets_properties_and_seals_the_type()
        {
            var entitySets = new[] { new EntitySet {
                                         Name = "Bar"
                                     } };

            var functionImports =
                new[]
            {
                new EdmFunction(
                    "foo",
                    "bar",
                    DataSpace.CSpace,
                    new EdmFunctionPayload()
                {
                    IsFunctionImport = true
                })
            };


            var entityContainer =
                EntityContainer.Create("Foo", DataSpace.SSpace, entitySets, functionImports,
                                       new[]
            {
                new MetadataProperty(
                    "TestProperty",
                    TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)),
                    "value"),
            });

            Assert.Equal("Foo", entityContainer.Name);
            Assert.Equal(entitySets, entityContainer.EntitySets);
            Assert.Equal(functionImports, entityContainer.FunctionImports);
            Assert.True(entityContainer.IsReadOnly);

            var metadataProperty = entityContainer.MetadataProperties.SingleOrDefault(p => p.Name == "TestProperty");

            Assert.NotNull(metadataProperty);
            Assert.Equal("value", metadataProperty.Value);
        }
Ejemplo n.º 3
0
        public void WriteContainer_writes_annotation_namespace_when_requested()
        {
            var container = EntityContainer.Create(
                "C", DataSpace.CSpace, new EntitySetBase[0], null,
                new[]
            {
                new MetadataProperty(
                    "http://schemas.microsoft.com/ado/2009/02/edm/annotation:LazyLoadingEnabled",
                    TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), "true")
            });

            var fixture = new Fixture();

            // WriteSchemaElementHeader binds the "annotation" namespace prefix to the annotation namespace uri
            fixture.Writer.WriteSchemaElementHeader("ns");
            fixture.Writer.WriteEntityContainerElementHeader(container);

            Assert.Equal(
                @"<Schema Namespace=""ns"" Alias=""Self"" annotation:UseStrongSpatialTypes=""false"" xmlns:annotation=""http://schemas.microsoft.com/ado/2009/02/edm/annotation"" xmlns:customannotation=""http://schemas.microsoft.com/ado/2013/11/edm/customannotation"" xmlns=""http://schemas.microsoft.com/ado/2009/11/edm"">" +
                @"<EntityContainer Name=""C"" annotation:LazyLoadingEnabled=""true""",
                fixture.ToString());
        }