예제 #1
0
        public void ParseString(string input, SqlTypeCode typeCode)
        {
            var sqlType = SqlType.Parse(input);

            Assert.IsNotNull(sqlType);
            Assert.IsInstanceOf <DateType>(sqlType);
            Assert.AreEqual(typeCode, sqlType.TypeCode);
        }
예제 #2
0
        public void ParseString(string input, SqlTypeCode expected)
        {
            var type = SqlType.Parse(input);

            Assert.IsNotNull(type);
            Assert.IsInstanceOf <IntervalType>(type);

            Assert.AreEqual(expected, type.TypeCode);
        }
예제 #3
0
        public void GeometryWithSrid()
        {
            const string typeString = "GEOMETRY(SRID = '2029')";

            SqlType type = null;

            Assert.DoesNotThrow(() => type = SqlType.Parse(Query.Context, typeString));
            Assert.IsNotNull(type);
            Assert.IsInstanceOf <SpatialType>(type);
            Assert.AreEqual(2029, ((SpatialType)type).Srid);
        }
예제 #4
0
        public void SimpleGeometry()
        {
            const string typeString = "GEOMETRY";

            SqlType type = null;

            Assert.DoesNotThrow(() => type = SqlType.Parse(Query.Context, typeString));
            Assert.IsNotNull(type);
            Assert.IsInstanceOf <SpatialType>(type);
            Assert.AreEqual(-1, ((SpatialType)type).Srid);
        }
예제 #5
0
        public void SimpleNumeric()
        {
            const string typeString = "NUMERIC";

            SqlType type = null;

            Assert.DoesNotThrow(() => type = SqlType.Parse(typeString));
            Assert.IsNotNull(type);
            Assert.IsInstanceOf <NumericType>(type);
            Assert.AreEqual(-1, ((NumericType)type).Size);
        }
예제 #6
0
        public void SizedVarChar_Parse()
        {
            const string typeString = "VARCHAR(255)";
            SqlType      sqlType    = null;

            Assert.DoesNotThrow(() => sqlType = SqlType.Parse(typeString));
            Assert.IsNotNull(sqlType);
            Assert.IsInstanceOf <StringType>(sqlType);
            Assert.AreEqual(SqlTypeCode.VarChar, sqlType.TypeCode);

            var stringType = (StringType)sqlType;

            Assert.AreEqual(255, stringType.MaxSize);
            Assert.AreEqual(null, stringType.Locale);
        }
예제 #7
0
        public void SizedWithEncoding_Parse()
        {
            const string typeString = "VARCHAR(255) ENCODING 'UTF-16'";
            SqlType      sqlType    = null;

            Assert.DoesNotThrow(() => sqlType = SqlType.Parse(typeString));
            Assert.IsNotNull(sqlType);
            Assert.IsInstanceOf <StringType>(sqlType);
            Assert.AreEqual(SqlTypeCode.VarChar, sqlType.TypeCode);

            var stringType = (StringType)sqlType;

            Assert.AreEqual(255, stringType.MaxSize);
            Assert.IsNull(stringType.Locale);
            Assert.AreEqual(Encoding.Unicode.WebName, stringType.Encoding.WebName);
        }
예제 #8
0
        public void LocalizedVarChar_Parse()
        {
            const string typeString = "VARCHAR(255) LOCALE 'en-Us'";
            SqlType      sqlType    = null;

            Assert.DoesNotThrow(() => sqlType = SqlType.Parse(typeString));
            Assert.IsNotNull(sqlType);
            Assert.IsInstanceOf <StringType>(sqlType);
            Assert.AreEqual(SqlTypeCode.VarChar, sqlType.TypeCode);

            var stringType = (StringType)sqlType;

            Assert.AreEqual(255, stringType.MaxSize);
            Assert.AreEqual(CultureInfo.GetCultureInfo("en-US"), stringType.Locale);
            Assert.IsNotNull(stringType.Encoding);
            Assert.AreEqual(Encoding.Unicode.WebName, stringType.Encoding.WebName);
        }
예제 #9
0
        public void SimpleGeometryWithNoContext()
        {
            const string typeString = "GEOMETRY";

            Assert.Throws <NotSupportedException>(() => SqlType.Parse(typeString));
        }