Exemplo n.º 1
0
        public virtual async Task Data_StoreShortDecimal()
        {
            //  test the "short" decimal storage capabilities, 15 digits
            var value = 123451234.512345m;

            await Data_TestStoreDataType(SqlDataType.Decimal(15, 6), value);
        }
Exemplo n.º 2
0
        public void Decimal_ReturnsDecimalDataTypeOfSpecifiedPrecisionAndScale(int?precision, int?scale)
        {
            var dataType = SqlDataType.Decimal(precision, scale);

            Assert.NotNull(dataType);
            Assert.Equal(SqlDataTypeNames.Decimal, dataType.Name);
            Assert.Equal(precision, dataType.Precision);
            Assert.Equal(scale, dataType.Scale);
        }
Exemplo n.º 3
0
        public static IEnumerable <object[]> WriteDataTypeData(bool lowerCase)
        {
            yield return(new object[] { SqlDataType.BigInt(), "BIGINT".ToLowerIf(lowerCase) });

            yield return(new object[] { SqlDataType.VarChar(16), "VARCHAR(16)".ToLowerIf(lowerCase) });

            yield return(new object[] { SqlDataType.Float(9), "FLOAT(9)".ToLowerIf(lowerCase) });

            yield return(new object[] { SqlDataType.Decimal(16), "DECIMAL(16)".ToLowerIf(lowerCase) });

            yield return(new object[] { SqlDataType.Decimal(16, 6), "DECIMAL(16, 6)".ToLowerIf(lowerCase) });
        }
Exemplo n.º 4
0
 public void Decimal_WithInvalidScale_ThrowsArgumentOutOfRange(int?precision, int?scale)
 {
     if (precision == null && scale != null)
     {
         var ex = Assert.Throws <ArgumentException>(() => SqlDataType.Decimal(precision, scale));
         Assert.Equal(nameof(scale), ex.ParamName);
     }
     else
     {
         var ex = Assert.Throws <ArgumentOutOfRangeException>(() => SqlDataType.Decimal(precision, scale));
         Assert.Equal(nameof(scale), ex.ParamName);
         Assert.Equal(scale, ex.ActualValue);
     }
 }
Exemplo n.º 5
0
 public virtual async Task Data_StoreWideDecimal()
 {
     //  test the full decimal storage capabilities of the engine using the max decimal value
     await Data_TestStoreDataType(SqlDataType.Decimal(38), decimal.MaxValue);
 }
Exemplo n.º 6
0
        public static IEnumerable <object[]> EqualsData(bool exactTypeOnly)
        {
            var dataType = new SqlDataType("FOOBAR");

            if (!exactTypeOnly)
            {
                yield return(new object[] { dataType, "FOOBAR", false });
            }
            yield return(new object[] { dataType, (SqlDataType)null, false });

            yield return(new object[] { dataType, new SqlDataType("NONE"), false });

            yield return(new object[] { dataType, new SqlDataType("FOOBAR"), true });

            yield return(new object[] { dataType, dataType, true });

            yield return(new object[] { SqlDataType.Int(), SqlDataType.Int(), true });

            yield return(new object[] { SqlDataType.Int(), SqlDataType.BigInt(), false });

            yield return(new object[] { SqlDataType.VarChar(5), SqlDataType.VarChar(10), false });

            yield return(new object[] { SqlDataType.VarChar(5), SqlDataType.Char(10), false });

            yield return(new object[] { SqlDataType.VarChar(5), SqlDataType.VarChar(5), true });

            yield return(new object[] { SqlDataType.VarChar(5), SqlDataType.Float(5), false });

            yield return(new object[] { SqlDataType.VarChar(5), SqlDataType.Float(6), false });

            yield return(new object[] { SqlDataType.VarChar(5), null, false });

            yield return(new object[] { SqlDataType.Float(), SqlDataType.Float(10), false });

            yield return(new object[] { SqlDataType.Float(), new SqlPrecisionDataType("DOUBLE"), false });

            yield return(new object[] { SqlDataType.Float(), SqlDataType.Float(), true });

            yield return(new object[] { SqlDataType.Float(5), SqlDataType.Float(10), false });

            yield return(new object[] { SqlDataType.Float(5), SqlDataType.Float(5), true });

            yield return(new object[] { SqlDataType.Float(5), SqlDataType.VarChar(42), false });

            yield return(new object[] { SqlDataType.Float(5), null, false });

            yield return(new object[] { SqlDataType.Decimal(), SqlDataType.Decimal(10, 3), false });

            yield return(new object[] { SqlDataType.Decimal(), SqlDataType.Float(10), false });

            yield return(new object[] { SqlDataType.Decimal(), SqlDataType.Decimal(), true });

            yield return(new object[] { SqlDataType.Decimal(5, 3), SqlDataType.Decimal(10, 3), false });

            yield return(new object[] { SqlDataType.Decimal(5, 3), SqlDataType.Decimal(5, 3), true });

            yield return(new object[] { SqlDataType.Decimal(5, 3), SqlDataType.VarChar(42), false });

            yield return(new object[] { SqlDataType.Decimal(5, 3), SqlDataType.Decimal(5, 4), false });

            yield return(new object[] { SqlDataType.Decimal(5, 3), null, false });


            var self = (SqlDataType)SqlDataType.VarChar(5);

            yield return(new object[] { self, self, true });

            self = SqlDataType.Float(5);
            yield return(new object[] { self, self, true });

            self = SqlDataType.Decimal(10, 3);
            yield return(new object[] { self, self, true });
        }