コード例 #1
0
        public void Create_creates_new_property()
        {
            var typeUsage =
                TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            var property = EdmProperty.Create("foo", typeUsage);

            Assert.Equal("foo", property.Name);
            Assert.Same(typeUsage, property.TypeUsage);
        }
コード例 #2
0
        public void Cannot_create_property_of_invalid_type()
        {
            var rowType =
                RowType.Create(
                    new[]
            {
                EdmProperty.Primitive("property", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32))
            },
                    null);

            Assert.Equal(
                Strings.EdmProperty_InvalidPropertyType(rowType.FullName),
                Assert.Throws <ArgumentException>(() => EdmProperty.Create("invalidProperty", TypeUsage.Create(rowType))).Message);
        }
コード例 #3
0
        public void SetMetadataProperties_sets_metadata_properties()
        {
            var typeUsage =
                TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            var property = EdmProperty.Create("foo", typeUsage);

            property.SetMetadataProperties(
                new List <MetadataProperty>
            {
                MetadataProperty.Create(
                    "foo", TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), "bar")
            });

            Assert.NotNull(property.MetadataProperties.SingleOrDefault(p => p.Name == "foo" && (string)p.Value == "bar"));
        }
コード例 #4
0
            public void CSpace_RowType_returned_for_SSpace_RowType()
            {
                var sSpaceTypeUsage =
                    FakeSqlProviderServices
                    .Instance.GetProviderManifest("2008")
                    .GetStoreType(TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)));

                var sSpaceRowTypeUsage =
                    TypeUsage.CreateDefaultTypeUsage(RowType.Create(new[] { EdmProperty.Create("foo", sSpaceTypeUsage) }, null));

                var cSpaceRowType = (RowType)sSpaceRowTypeUsage.ModelTypeUsage.EdmType;

                Assert.Equal(DataSpace.CSpace, cSpaceRowType.GetDataSpace());
                Assert.Equal(1, cSpaceRowType.Properties.Count);
                Assert.Equal(DataSpace.CSpace, cSpaceRowType.Properties.Single().TypeUsage.EdmType.GetDataSpace());
                Assert.Equal("foo", cSpaceRowType.Properties.Single().Name);
                Assert.Equal(
                    PrimitiveTypeKind.String,
                    ((PrimitiveType)cSpaceRowType.Properties.Single().TypeUsage.EdmType).PrimitiveTypeKind);
            }