Пример #1
0
 private void InitializePrimitiveType(
     PrimitiveType primitiveType,
     PrimitiveTypeKind primitiveTypeKind,
     string name,
     Type clrType)
 {
     EdmType.Initialize((EdmType)primitiveType, name, "Edm", DataSpace.CSpace, true, (EdmType)null);
     PrimitiveType.Initialize(primitiveType, primitiveTypeKind, (DbProviderManifest)this);
 }
        private void Assert_Timestamp(BinaryPropertyConfiguration binaryPropertyConfiguration)
        {
            var property = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            binaryPropertyConfiguration.Configure(property);

            Assert.Equal("String", property.TypeName);
            Assert.Equal(false, property.Nullable);
            Assert.Equal(ConcurrencyMode.Fixed, property.ConcurrencyMode);
            Assert.Equal(StoreGeneratedPattern.Computed, property.GetStoreGeneratedPattern());
            Assert.Equal(8, property.MaxLength.Value);

            var primitiveType = new PrimitiveType();

            EdmType.Initialize(primitiveType, "rowversion", "N", DataSpace.SSpace, false, null);
            var mockDbProviderManifest = new Mock <DbProviderManifest>();

            mockDbProviderManifest.Setup(m => m.GetStoreTypes())
            .Returns(new ReadOnlyCollection <PrimitiveType>(new List <PrimitiveType> {
                primitiveType
            }));
            mockDbProviderManifest.Setup(m => m.GetFacetDescriptions(It.IsAny <EdmType>()))
            .Returns(new ReadOnlyCollection <FacetDescription>(new List <FacetDescription>()));
            PrimitiveType.Initialize(primitiveType, PrimitiveTypeKind.Binary, mockDbProviderManifest.Object);

            var column = EdmProperty.CreatePrimitive("P", PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.String));

            binaryPropertyConfiguration.Configure(
                column,
                new EntityType("E", "N", DataSpace.SSpace),
                mockDbProviderManifest.Object);

            Assert.Equal("rowversion", column.TypeName);
            Assert.Equal(true, column.Nullable);
            Assert.Equal(ConcurrencyMode.None, column.ConcurrencyMode);
            Assert.Null(column.GetStoreGeneratedPattern());
            Assert.Null(column.MaxLength);
        }