Example #1
0
        public void EntityMetadataBuilderGenericNumericProperty()
        {
            var builder = new MetadataModelBuilder().Entity <AllTypesEntity>();

            var prop = builder.Property(p => p.NullableByteProperty);

            Assert.Equal(NumericPropertyType.Byte, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.ByteProperty);
            Assert.Equal(NumericPropertyType.Byte, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableSByteProperty);
            Assert.Equal(NumericPropertyType.SByte, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.SByteProperty);
            Assert.Equal(NumericPropertyType.SByte, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableShortProperty);
            Assert.Equal(NumericPropertyType.Int16, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.ShortProperty);
            Assert.Equal(NumericPropertyType.Int16, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableUShortProperty);
            Assert.Equal(NumericPropertyType.UInt16, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.UShortProperty);
            Assert.Equal(NumericPropertyType.UInt16, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableIntProperty);
            Assert.Equal(NumericPropertyType.Int32, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.IntProperty);
            Assert.Equal(NumericPropertyType.Int32, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableUIntProperty);
            Assert.Equal(NumericPropertyType.UInt32, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.UIntProperty);
            Assert.Equal(NumericPropertyType.UInt32, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableLongProperty);
            Assert.Equal(NumericPropertyType.Int64, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.LongProperty);
            Assert.Equal(NumericPropertyType.Int64, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableULongProperty);
            Assert.Equal(NumericPropertyType.UInt64, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.ULongProperty);
            Assert.Equal(NumericPropertyType.UInt64, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableFloatProperty);
            Assert.Equal(NumericPropertyType.Single, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.FloatProperty);
            Assert.Equal(NumericPropertyType.Single, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableDoubleProperty);
            Assert.Equal(NumericPropertyType.Double, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.DoubleProperty);
            Assert.Equal(NumericPropertyType.Double, prop.NumericType);
            Assert.False(prop.Nullable);

            prop = builder.Property(p => p.NullableDecimalProperty);
            Assert.Equal(NumericPropertyType.Decimal, prop.NumericType);
            Assert.True(prop.Nullable);

            prop = builder.Property(p => p.DecimalProperty);
            Assert.Equal(NumericPropertyType.Decimal, prop.NumericType);
            Assert.False(prop.Nullable);
        }