Beispiel #1
0
        private static void BinaryWithInterval(Func <SqlDateTimeType, Func <ISqlValue, ISqlValue, ISqlValue> > selector, string date, string offset, string expected)
        {
            var type    = new SqlDateTimeType(SqlTypeCode.DateTime);
            var sqlDate = SqlDateTime.Parse(date);
            var dts     = SqlDayToSecond.Parse(offset);

            var op     = selector(type);
            var result = op(sqlDate, dts);

            var expectedResult = SqlDateTime.Parse(expected);

            Assert.Equal(expectedResult, result);
        }
        public static void CastToString(string value, SqlTypeCode destTypeCode, int size, string expexted)
        {
            var dts = SqlDayToSecond.Parse(value);

            var type     = new SqlDayToSecondType();
            var destType = PrimitiveTypes.Type(destTypeCode, new { size });
            var result   = type.Cast(dts, destType);

            var exp = SqlValueUtil.FromObject(expexted);

            Assert.NotNull(result);
            Assert.Equal(exp, result);
        }
        private static void Binary(Func <SqlType, Func <ISqlValue, ISqlValue, ISqlValue> > selector,
                                   string value1,
                                   string value2,
                                   string expected)
        {
            var type = new SqlDayToSecondType();

            var a = SqlDayToSecond.Parse(value1);
            var b = SqlDayToSecond.Parse(value2);

            var op     = selector(type);
            var result = op(a, b);

            var exp = SqlDayToSecond.Parse(expected);

            Assert.Equal(exp, result);
        }
        public static void CastToBinary(string value, SqlTypeCode destTypeCode, int size)
        {
            var dts = SqlDayToSecond.Parse(value);

            var type     = new SqlDayToSecondType();
            var destType = PrimitiveTypes.Type(destTypeCode, new { size });
            var result   = type.Cast(dts, destType);

            Assert.IsType <SqlBinary>(result);

            var binary = (SqlBinary)result;
            var bytes  = binary.ToByteArray();

            var back = new SqlDayToSecond(bytes);

            Assert.Equal(dts, back);
        }
        public static void CastToDayToSecond(string s, string expected)
        {
            var expectedResult = SqlDayToSecond.Parse(expected);

            Cast(s, SqlTypeCode.DayToSecond, -1, -1, expectedResult);
        }