public void Create_factory_method_sets_properties_and_seals_the_type() { var rowType = RowType.Create( new[] { EdmProperty.Primitive("foo", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), EdmProperty.Primitive("bar", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int64)) }, new[] { new MetadataProperty( "TestProperty", TypeUsage.CreateDefaultTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String)), "baz") } ); Assert.NotNull(rowType); Assert.Equal(new[] { "foo", "bar" }, rowType.Properties.Select(p => p.Name)); var metadataProperty = rowType.MetadataProperties.SingleOrDefault(p => p.Name == "TestProperty"); Assert.NotNull(metadataProperty); Assert.Equal("baz", metadataProperty.Value); Assert.True(rowType.IsReadOnly); }
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); }
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); }