DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | List of all members
Deveel.Data.Sql.Expressions.SqlCastExpressionTests Class Reference

Public Member Functions

void CastStringToInteger ()
 
void CastStringToNumber ()
 
void CastStringToDateTime ()
 
void CastStringToDate ()
 
void CastStringToTime ()
 
void CastStringToBooleanTrue ()
 
void CastStringToBooleanFalse ()
 
void CastBooleanFalseToString ()
 
void CastBooleanTrueToString ()
 
void CastDateToString ()
 
void CastNumberToString ()
 

Detailed Description

Definition at line 24 of file SqlCastExpressionTests.cs.

Member Function Documentation

void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastBooleanFalseToString ( )
inline

Definition at line 145 of file SqlCastExpressionTests.cs.

145  {
146  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.Boolean(false)), PrimitiveTypes.String());
147 
148  SqlExpression casted = null;
149  Assert.DoesNotThrow(() => casted = exp.Evaluate());
150  Assert.IsNotNull(casted);
151  Assert.IsInstanceOf<SqlConstantExpression>(casted);
152 
153  var value = ((SqlConstantExpression)casted).Value;
154  Assert.IsNotNull(value.Value);
155  Assert.IsInstanceOf<StringType>(value.Type);
156  Assert.AreEqual(SqlTypeCode.String, value.Type.TypeCode);
157  Assert.AreEqual(new SqlString("False"), value.Value);
158  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastBooleanTrueToString ( )
inline

Definition at line 161 of file SqlCastExpressionTests.cs.

161  {
162  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.Boolean(true)), PrimitiveTypes.String());
163 
164  SqlExpression casted = null;
165  Assert.DoesNotThrow(() => casted = exp.Evaluate());
166  Assert.IsNotNull(casted);
167  Assert.IsInstanceOf<SqlConstantExpression>(casted);
168 
169  var value = ((SqlConstantExpression)casted).Value;
170  Assert.IsNotNull(value.Value);
171  Assert.IsInstanceOf<StringType>(value.Type);
172  Assert.AreEqual(SqlTypeCode.String, value.Type.TypeCode);
173  Assert.AreEqual(new SqlString("True"), value.Value);
174  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastDateToString ( )
inline

Definition at line 177 of file SqlCastExpressionTests.cs.

177  {
178  var date = DataObject.Date(new SqlDateTime(2015, 02, 03));
179  var exp = SqlExpression.Cast(SqlExpression.Constant(date), PrimitiveTypes.String());
180 
181  SqlExpression casted = null;
182  Assert.DoesNotThrow(() => casted = exp.Evaluate());
183  Assert.IsNotNull(casted);
184  Assert.IsInstanceOf<SqlConstantExpression>(casted);
185 
186  var value = ((SqlConstantExpression)casted).Value;
187  Assert.IsNotNull(value.Value);
188  Assert.IsInstanceOf<StringType>(value.Type);
189  Assert.AreEqual(SqlTypeCode.String, value.Type.TypeCode);
190  Assert.AreEqual(new SqlString("2015-02-03"), value.Value);
191  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
Deveel.Data.Sql.Objects.SqlString SqlString
Definition: DataObject.cs:27
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastNumberToString ( )
inline

Definition at line 194 of file SqlCastExpressionTests.cs.

194  {
195  Assert.Inconclusive();
196  }
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToBooleanFalse ( )
inline

Definition at line 129 of file SqlCastExpressionTests.cs.

129  {
130  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("false")), PrimitiveTypes.Boolean());
131 
132  SqlExpression casted = null;
133  Assert.DoesNotThrow(() => casted = exp.Evaluate());
134  Assert.IsNotNull(casted);
135  Assert.IsInstanceOf<SqlConstantExpression>(casted);
136 
137  var value = ((SqlConstantExpression)casted).Value;
138  Assert.IsNotNull(value.Value);
139  Assert.IsInstanceOf<BooleanType>(value.Type);
140  Assert.AreEqual(SqlTypeCode.Boolean, value.Type.TypeCode);
141  Assert.AreEqual(SqlBoolean.False, value.Value);
142  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static BooleanType Boolean()
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToBooleanTrue ( )
inline

Definition at line 113 of file SqlCastExpressionTests.cs.

113  {
114  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("true")), PrimitiveTypes.Boolean());
115 
116  SqlExpression casted = null;
117  Assert.DoesNotThrow(() => casted = exp.Evaluate());
118  Assert.IsNotNull(casted);
119  Assert.IsInstanceOf<SqlConstantExpression>(casted);
120 
121  var value = ((SqlConstantExpression)casted).Value;
122  Assert.IsNotNull(value.Value);
123  Assert.IsInstanceOf<BooleanType>(value.Type);
124  Assert.AreEqual(SqlTypeCode.Boolean, value.Type.TypeCode);
125  Assert.AreEqual(SqlBoolean.True, value.Value);
126  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static BooleanType Boolean()
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToDate ( )
inline

Definition at line 74 of file SqlCastExpressionTests.cs.

74  {
75  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("2015-09-01")), PrimitiveTypes.Date());
76 
77  SqlExpression casted = null;
78  Assert.DoesNotThrow(() => casted = exp.Evaluate());
79  Assert.IsNotNull(casted);
80  Assert.IsInstanceOf<SqlConstantExpression>(casted);
81 
82  var value = ((SqlConstantExpression)casted).Value;
83  Assert.IsNotNull(value.Value);
84  Assert.IsInstanceOf<DateType>(value.Type);
85  Assert.AreEqual(SqlTypeCode.Date, value.Type.TypeCode);
86  Assert.AreEqual(new SqlDateTime(2015, 09, 01), value.Value);
87  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToDateTime ( )
inline

Definition at line 58 of file SqlCastExpressionTests.cs.

58  {
59  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("2015-09-01")), PrimitiveTypes.DateTime());
60 
61  SqlExpression casted = null;
62  Assert.DoesNotThrow(() => casted = exp.Evaluate());
63  Assert.IsNotNull(casted);
64  Assert.IsInstanceOf<SqlConstantExpression>(casted);
65 
66  var value = ((SqlConstantExpression)casted).Value;
67  Assert.IsNotNull(value.Value);
68  Assert.IsInstanceOf<DateType>(value.Type);
69  Assert.AreEqual(SqlTypeCode.DateTime, value.Type.TypeCode);
70  Assert.AreEqual(new SqlDateTime(2015, 09, 01), value.Value);
71  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToInteger ( )
inline

Definition at line 26 of file SqlCastExpressionTests.cs.

26  {
27  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("1234")), PrimitiveTypes.Integer());
28 
29  SqlExpression casted = null;
30  Assert.DoesNotThrow(() => casted = exp.Evaluate());
31  Assert.IsNotNull(casted);
32  Assert.IsInstanceOf<SqlConstantExpression>(casted);
33 
34  var value = ((SqlConstantExpression) casted).Value;
35  Assert.IsNotNull(value.Value);
36  Assert.IsInstanceOf<NumericType>(value.Type);
37  Assert.AreEqual(SqlTypeCode.Integer, value.Type.TypeCode);
38  Assert.AreEqual(new SqlNumber(1234), value.Value);
39  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToNumber ( )
inline

Definition at line 42 of file SqlCastExpressionTests.cs.

42  {
43  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("12.3e4")), PrimitiveTypes.Numeric());
44 
45  SqlExpression casted = null;
46  Assert.DoesNotThrow(() => casted = exp.Evaluate());
47  Assert.IsNotNull(casted);
48  Assert.IsInstanceOf<SqlConstantExpression>(casted);
49 
50  var value = ((SqlConstantExpression)casted).Value;
51  Assert.IsNotNull(value.Value);
52  Assert.IsInstanceOf<NumericType>(value.Type);
53  Assert.AreEqual(SqlTypeCode.Numeric, value.Type.TypeCode);
54  Assert.AreEqual(SqlNumber.Parse("12.3e4"), value.Value);
55  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static NumericType Numeric()
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23
static SqlNumber Parse(string s)
Definition: SqlNumber.cs:738
void Deveel.Data.Sql.Expressions.SqlCastExpressionTests.CastStringToTime ( )
inline

Definition at line 90 of file SqlCastExpressionTests.cs.

90  {
91  var exp = SqlExpression.Cast(SqlExpression.Constant(DataObject.String("22:13:01")), PrimitiveTypes.Time());
92 
93  SqlExpression casted = null;
94  Assert.DoesNotThrow(() => casted = exp.Evaluate());
95  Assert.IsNotNull(casted);
96  Assert.IsInstanceOf<SqlConstantExpression>(casted);
97 
98  var value = ((SqlConstantExpression)casted).Value;
99  Assert.IsNotNull(value.Value);
100  Assert.IsInstanceOf<DateType>(value.Type);
101  Assert.AreEqual(SqlTypeCode.Time, value.Type.TypeCode);
102 
103  // we round the expected value to the result offset because of the UTC parsing logic
104  // of the date type: all we care here is the time component
105 
106  var result = ((SqlDateTime)value.Value);
107  var expected = new SqlDateTime(1, 1, 1, 22, 13, 01, 0, result.Offset);
108  Assert.AreEqual(expected, result);
109  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
SqlTypeCode
Enumerates the codes of all SQL types handled by the system.
Definition: SqlTypeCode.cs:23

The documentation for this class was generated from the following file: