DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
Deveel.Data.Sql.Statements.UpdateStatementTests Class Reference
Inheritance diagram for Deveel.Data.Sql.Statements.UpdateStatementTests:
Deveel.Data.ContextBasedTest

Public Member Functions

void ParseSimpleUpdate ()
 
void ParseSimpleUpdateWithLimit ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Protected Member Functions

override IQuery CreateQuery (ISession session)
 
- Protected Member Functions inherited from Deveel.Data.ContextBasedTest
virtual void RegisterServices (ServiceContainer container)
 
virtual ISystem CreateSystem ()
 
virtual IDatabase CreateDatabase (ISystem system, IConfiguration configuration)
 
virtual ISession CreateAdminSession (IDatabase database)
 
ISession CreateUserSession (string userName, string password)
 
virtual void OnSetUp (string testName)
 
virtual void OnTearDown ()
 

Private Member Functions

void CreateTestTable (IQuery context)
 
void AddTestData (IQuery context)
 

Additional Inherited Members

- Protected Attributes inherited from Deveel.Data.ContextBasedTest
const string AdminUserName = "SA"
 
const string AdminPassword = "1234567890"
 
const string DatabaseName = "testdb"
 
- Properties inherited from Deveel.Data.ContextBasedTest
virtual bool SingleContext [get]
 
IQuery Query [get, private set]
 
ISystem System [get, private set]
 
IDatabase Database [get, private set]
 
ISession Session [get, private set]
 

Detailed Description

Definition at line 29 of file UpdateStatementTests.cs.

Member Function Documentation

void Deveel.Data.Sql.Statements.UpdateStatementTests.AddTestData ( IQuery  context)
inlineprivate

Definition at line 51 of file UpdateStatementTests.cs.

51  {
52  var table = context.GetMutableTable(ObjectName.Parse("APP.test_table"));
53  var row = table.NewRow();
54  row.SetValue("id", DataObject.Integer(0));
55  row.SetValue("first_name", DataObject.String("John"));
56  row.SetValue("last_name", DataObject.String("Doe"));
57  row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1977, 01, 01)));
58  row.SetValue("active", DataObject.Boolean(false));
59  table.AddRow(row);
60 
61  row = table.NewRow();
62  row.SetValue("id", DataObject.Integer(1));
63  row.SetValue("first_name", DataObject.String("Jane"));
64  row.SetValue("last_name", DataObject.String("Doe"));
65  row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1978, 11, 01)));
66  row.SetValue("active", DataObject.Boolean(true));
67  table.AddRow(row);
68 
69  row = table.NewRow();
70  row.SetValue("id", DataObject.Integer(2));
71  row.SetValue("first_name", DataObject.String("Roger"));
72  row.SetValue("last_name", DataObject.String("Rabbit"));
73  row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1985, 05, 05)));
74  row.SetValue("active", DataObject.Boolean(true));
75  table.AddRow(row);
76  }
static DataObject Date(DateTimeOffset value)
Definition: DataObject.cs:600
static DataObject Integer(int value)
Definition: DataObject.cs:576
static DataObject String(string s)
Definition: DataObject.cs:592
static DataObject Boolean(SqlBoolean value)
Definition: DataObject.cs:544
Represents a dynamic object that encapsulates a defined SqlType and a compatible constant ISqlObject ...
Definition: DataObject.cs:35
override IQuery Deveel.Data.Sql.Statements.UpdateStatementTests.CreateQuery ( ISession  session)
inlineprotectedvirtual

Reimplemented from Deveel.Data.ContextBasedTest.

Definition at line 30 of file UpdateStatementTests.cs.

30  {
31  var query = base.CreateQuery(session);
32  CreateTestTable(query);
33  AddTestData(query);
34  return query;
35  }
void Deveel.Data.Sql.Statements.UpdateStatementTests.CreateTestTable ( IQuery  context)
inlineprivate

Definition at line 37 of file UpdateStatementTests.cs.

37  {
38  var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table"));
39  var idColumn = tableInfo.AddColumn("id", PrimitiveTypes.Integer());
40  idColumn.DefaultExpression = SqlExpression.FunctionCall("UNIQUE_KEY",
41  new SqlExpression[] { SqlExpression.Reference(tableInfo.TableName) });
42  tableInfo.AddColumn("first_name", PrimitiveTypes.String());
43  tableInfo.AddColumn("last_name", PrimitiveTypes.String());
44  tableInfo.AddColumn("birth_date", PrimitiveTypes.DateTime());
45  tableInfo.AddColumn("active", PrimitiveTypes.Boolean());
46 
47  context.CreateTable(tableInfo);
48  context.AddPrimaryKey(tableInfo.TableName, "id", "PK_TEST_TABLE");
49  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static BooleanType Boolean()
void AddColumn(ColumnInfo column)
Adds a new column to the table at the last position of the columns list in the table metadata...
Definition: TableInfo.cs:230
static SqlReferenceExpression Reference(ObjectName objectName)
Defines the base class for instances that represent SQL expression tree nodes.
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
void Deveel.Data.Sql.Statements.UpdateStatementTests.ParseSimpleUpdate ( )
inline

Definition at line 79 of file UpdateStatementTests.cs.

79  {
80  const string sql = "UPDATE table SET col1 = 'testUpdate', col2 = 22 WHERE id = 1";
81 
82  IEnumerable<SqlStatement> statements = null;
83  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
84  Assert.IsNotNull(statements);
85 
86  var statement = statements.FirstOrDefault();
87 
88  Assert.IsNotNull(statement);
89  Assert.IsInstanceOf<UpdateStatement>(statement);
90  }
void Deveel.Data.Sql.Statements.UpdateStatementTests.ParseSimpleUpdateWithLimit ( )
inline

Definition at line 93 of file UpdateStatementTests.cs.

93  {
94  const string sql = "UPDATE table SET col1 = 'testUpdate', col2 = 22 WHERE id = 1 LIMIT 20";
95 
96  IEnumerable<SqlStatement> statements = null;
97  Assert.DoesNotThrow(() => statements = SqlStatement.Parse(sql));
98  Assert.IsNotNull(statements);
99 
100  var statement = statements.FirstOrDefault();
101 
102  Assert.IsNotNull(statement);
103  Assert.IsInstanceOf<UpdateStatement>(statement);
104  }

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