Exemplo n.º 1
0
        public void BigInt_ReturnsBigIntDataType()
        {
            var dataType = SqlDataType.BigInt();

            Assert.NotNull(dataType);
            Assert.Equal(SqlDataTypeNames.BigInt, dataType.Name);
        }
Exemplo n.º 2
0
        public void Cast_WithValueAndDataType_ReturnsCast()
        {
            var cast = SqlExpression.Cast(5, SqlDataType.BigInt());

            Assert.Equal(5, cast.Value);
            Assert.Equal(SqlDataType.BigInt(), cast.DataType);
        }
Exemplo n.º 3
0
        public void Ctor_WithValueAndDataType_SetsValueAndDataTypeProperties()
        {
            var cast = new SqlCast(5, SqlDataType.BigInt());

            Assert.Equal(5, cast.Value);
            Assert.Equal(SqlDataType.BigInt(), cast.DataType);
        }
Exemplo n.º 4
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.º 5
0
        public void Accept_WithCast_VisitsEverything()
        {
            var fixture = new Fixture().Customize(new AutoMoqCustomization());
            var mock    = fixture.Freeze <Mock <SqlVisitor> >();

            var query = Sql
                        .Select(SqlExpression.Cast((SqlColumn)"Age", SqlDataType.BigInt()))
                        .From("User")
                        .Go();

            query.Accept(mock.Object);

            mock.Verify(_ => _.Visit(It.IsAny <SqlCast>()), Times.Once);
        }
Exemplo n.º 6
0
 public virtual async Task Data_StoreBigInt()
 {
     await Data_TestStoreDataType(SqlDataType.BigInt(), long.MaxValue);
 }
Exemplo n.º 7
0
        public void Cast_WithNullValue_ConvertsToNullConstant()
        {
            var cast = SqlExpression.Cast(null, SqlDataType.BigInt());

            Assert.Same(SqlConstant.Null, cast.Value);
        }
Exemplo n.º 8
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 });
        }
Exemplo n.º 9
0
        public void Ctor_WithNullValue_ConvertsToNullConstant()
        {
            var cast = new SqlCast(null, SqlDataType.BigInt());

            Assert.Same(SqlConstant.Null, cast.Value);
        }