17 using System.Globalization;
20 using NUnit.Framework;
22 namespace Deveel.Data.Types {
24 [Category(
"Data Types")]
29 Assert.AreEqual(
SqlTypeCode.VarChar, type.TypeCode);
30 Assert.AreEqual(Int16.MaxValue, type.MaxSize);
31 Assert.IsTrue(type.IsPrimitive);
32 Assert.IsTrue(type.IsIndexable);
33 Assert.
IsNull(type.Locale);
41 Assert.AreEqual(type1.TypeCode, type2.TypeCode);
42 Assert.IsTrue(type1.IsComparable(type2));
43 Assert.IsTrue(type1.CanCastTo(type2));
48 const string typeString =
"VARCHAR";
50 Assert.DoesNotThrow(() => sqlType =
SqlType.
Parse(typeString));
51 Assert.IsNotNull(sqlType);
56 Assert.AreEqual(Int16.MaxValue, stringType.MaxSize);
57 Assert.AreEqual(null, stringType.Locale);
63 Assert.AreEqual(
SqlTypeCode.VarChar, type.TypeCode);
64 Assert.AreEqual(255, type.MaxSize);
72 Assert.AreEqual(type1.TypeCode, type2.TypeCode);
73 Assert.IsFalse(type1.Equals(type2));
74 Assert.IsTrue(type1.IsComparable(type2));
79 const string typeString =
"VARCHAR(255)";
81 Assert.DoesNotThrow(() => sqlType =
SqlType.
Parse(typeString));
82 Assert.IsNotNull(sqlType);
87 Assert.AreEqual(255, stringType.MaxSize);
88 Assert.AreEqual(null, stringType.Locale);
93 const string typeString =
"VARCHAR(255) LOCALE 'en-Us'";
95 Assert.DoesNotThrow(() => sqlType =
SqlType.
Parse(typeString));
96 Assert.IsNotNull(sqlType);
101 Assert.AreEqual(255, stringType.MaxSize);
102 Assert.AreEqual(CultureInfo.GetCultureInfo(
"en-US"), stringType.Locale);
103 Assert.IsNotNull(stringType.Encoding);
104 Assert.AreEqual(Encoding.Unicode.WebName, stringType.Encoding.WebName);
108 [Category(
"Strings"), Category(
"SQL Parse")]
110 const string typeString =
"VARCHAR(255) LOCALE 'en-Us' ENCODING 'UTF-16'";
112 Assert.DoesNotThrow(() => sqlType =
SqlType.
Parse(typeString));
113 Assert.IsNotNull(sqlType);
118 Assert.AreEqual(255, stringType.MaxSize);
119 Assert.AreEqual(CultureInfo.GetCultureInfo(
"en-US"), stringType.Locale);
120 Assert.AreEqual(Encoding.Unicode.WebName, stringType.Encoding.WebName);
124 [Category(
"Strings"), Category(
"SQL Parse")]
126 const string typeString =
"VARCHAR(255) ENCODING 'UTF-16'";
128 Assert.DoesNotThrow(() => sqlType =
SqlType.
Parse(typeString));
129 Assert.IsNotNull(sqlType);
134 Assert.AreEqual(255, stringType.MaxSize);
135 Assert.
IsNull(stringType.Locale);
136 Assert.AreEqual(Encoding.Unicode.WebName, stringType.Encoding.WebName);
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
void BasicVarChar_Parse()
void LocalizedWithEncodingVarChar_Parse()
void SizedWithEncoding_Parse()
void SizedVarChar_Parse()
void SizedVarChar_Compare()
SqlTypeCode TypeCode
Gets the kind of SQL type this data-type handles.
void BasicVarChar_Compare()
void BasicVarChar_Create()
Defines the properties of a specific SQL Type and handles the values compatible.
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
static StringType String()
void LocalizedVarChar_Parse()
void SizedVarChar_Create()
static SqlType Parse(string s)
Parses a SQL formatted string that defines a data-type into a constructed SqlType object equivalent...