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

Classes

class  Person
 
class  TestQueryContext
 

Public Member Functions

void TestSetup ()
 
void ProjectFirst ()
 
void FindById ()
 
void QueryById ()
 
- Public Member Functions inherited from Deveel.Data.ContextBasedTest
void TestSetUp ()
 
void TestFixtureSetUp ()
 
void TestTearDown ()
 
void TestFixtureTearDown ()
 

Protected Member Functions

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

Properties

QueryContext Context [get, set]
 
- 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]
 

Private Member Functions

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

Private Attributes

ITable table
 

Additional Inherited Members

- Protected Attributes inherited from Deveel.Data.ContextBasedTest
const string AdminUserName = "SA"
 
const string AdminPassword = "1234567890"
 
const string DatabaseName = "testdb"
 

Detailed Description

Definition at line 12 of file TableQueryTests.cs.

Member Function Documentation

void Deveel.Data.Linq.TableQueryTests.AddTestData ( IQuery  context)
inlineprivate

Definition at line 44 of file TableQueryTests.cs.

44  {
45  var table = context.GetMutableTable(ObjectName.Parse("APP.people"));
46  var row = table.NewRow();
47 
48  // row.SetValue("id", DataObject.Integer(0));
49  row.SetDefault(0, context);
50  row.SetValue("first_name", DataObject.String("John"));
51  row.SetValue("last_name", DataObject.String("Doe"));
52  row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1977, 01, 01)));
53  row.SetValue("active", DataObject.Boolean(false));
54  table.AddRow(row);
55 
56  row = table.NewRow();
57 
58  // row.SetValue("id", DataObject.Integer(1));
59  row.SetDefault(0, context);
60  row.SetValue("first_name", DataObject.String("Jane"));
61  row.SetValue("last_name", DataObject.String("Doe"));
62  row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1978, 11, 01)));
63  row.SetValue("active", DataObject.Boolean(true));
64  table.AddRow(row);
65 
66  row = table.NewRow();
67 
68  // row.SetValue("id", DataObject.Integer(2));
69  row.SetDefault(0, context);
70  row.SetValue("first_name", DataObject.String("Roger"));
71  row.SetValue("last_name", DataObject.String("Rabbit"));
72  row.SetValue("birth_date", DataObject.Date(new SqlDateTime(1985, 05, 05)));
73  row.SetValue("active", DataObject.Boolean(true));
74  table.AddRow(row);
75 
76  context.Commit();
77  }
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
Definition: ObjectName.cs:139
Describes the name of an object within a database.
Definition: ObjectName.cs:44
override ISession Deveel.Data.Linq.TableQueryTests.CreateAdminSession ( IDatabase  database)
inlineprotectedvirtual

Reimplemented from Deveel.Data.ContextBasedTest.

Definition at line 17 of file TableQueryTests.cs.

17  {
18  using (var session = base.CreateAdminSession(database)) {
19  using (var query = session.CreateQuery()) {
20  CreateTestTable(query);
21  AddTestData(query);
22 
23  query.Commit();
24  }
25  }
26 
27  return base.CreateAdminSession(database);
28  }
void AddTestData(IQuery context)
void CreateTestTable(IQuery context)
void Deveel.Data.Linq.TableQueryTests.CreateTestTable ( IQuery  context)
inlineprivate

Definition at line 30 of file TableQueryTests.cs.

30  {
31  var tableInfo = new TableInfo(ObjectName.Parse("APP.people"));
32  var idColumn = tableInfo.AddColumn("id", PrimitiveTypes.Integer());
33  idColumn.DefaultExpression = SqlExpression.FunctionCall("UNIQUEKEY",
34  new SqlExpression[] { SqlExpression.Constant(tableInfo.TableName.FullName) });
35  tableInfo.AddColumn("first_name", PrimitiveTypes.String());
36  tableInfo.AddColumn("last_name", PrimitiveTypes.String());
37  tableInfo.AddColumn("birth_date", PrimitiveTypes.DateTime());
38  tableInfo.AddColumn("active", PrimitiveTypes.Boolean());
39 
40  context.CreateTable(tableInfo);
41  context.AddPrimaryKey(tableInfo.TableName, "id", "PK_PEOPLE_TABLE");
42  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
Definition: ObjectName.cs:139
static BooleanType Boolean()
Describes the name of an object within a database.
Definition: ObjectName.cs:44
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
Defines the base class for instances that represent SQL expression tree nodes.
static SqlConstantExpression Constant(object value)
static SqlFunctionCallExpression FunctionCall(ObjectName functionName)
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41
void Deveel.Data.Linq.TableQueryTests.FindById ( )
inline

Definition at line 84 of file TableQueryTests.cs.

84  {
85  Person entity = null;
86  Assert.DoesNotThrow(() => entity = Context.Table<Person>().FindById(1));
87  Assert.IsNotNull(entity);
88  Assert.AreEqual(1, entity.Id);
89  Assert.AreEqual("John", entity.FirstName);
90  }
override void Deveel.Data.Linq.TableQueryTests.OnSetUp ( string  testName)
inlineprotectedvirtual

Reimplemented from Deveel.Data.ContextBasedTest.

Definition at line 79 of file TableQueryTests.cs.

79  {
80  Context = new TestQueryContext(Query);
81  }
void Deveel.Data.Linq.TableQueryTests.ProjectFirst ( )
inline

Definition at line 42 of file TableQueryTests.cs.

42  {
43  IQueryable<Person> queryable = null;
44  Assert.DoesNotThrow(() => queryable = table.AsQueryable<Person>());
45  Assert.IsNotNull(queryable);
46 
47  Person first = null;
48  Assert.DoesNotThrow(() => first = queryable.First());
49  Assert.IsNotNull(first);
50  Assert.AreEqual("Antonello", first.FirstName);
51  Assert.AreEqual("Provenzano", first.LastName);
52  Assert.AreEqual(1, first.Id);
53  Assert.AreEqual(0, first.Age);
54  }
void Deveel.Data.Linq.TableQueryTests.QueryById ( )
inline

Definition at line 93 of file TableQueryTests.cs.

93  {
94  Person entity = null;
95  Assert.DoesNotThrow(() => entity = Context.Table<Person>().FirstOrDefault(x => x.Id == 1));
96  Assert.IsNotNull(entity);
97  Assert.AreEqual(1, entity.Id);
98  Assert.AreEqual("John", entity.FirstName);
99  }
void Deveel.Data.Linq.TableQueryTests.TestSetup ( )
inline

Definition at line 16 of file TableQueryTests.cs.

16  {
17  var tableInfo = new TableInfo(ObjectName.Parse("APP.people"));
18  tableInfo.AddColumn("id", PrimitiveTypes.Bit());
19  tableInfo.AddColumn("first_name", PrimitiveTypes.String(), true);
20  tableInfo.AddColumn("last_name", PrimitiveTypes.String());
21  tableInfo.AddColumn("age", PrimitiveTypes.TinyInt());
22  table = new TemporaryTable(tableInfo);
23 
24  var tempTable = (TemporaryTable) table;
25  tempTable.NewRow(new[] {
26  DataObject.BigInt(1),
27  DataObject.String("Antonello"),
28  DataObject.String("Provenzano"),
29  DataObject.Null()
30  });
31  tempTable.NewRow(new[] {
32  DataObject.BigInt(2),
33  DataObject.String("Moritz"),
34  DataObject.String("Krull"),
35  DataObject.TinyInt(31)
36  });
37 
38  tempTable.BuildIndexes();
39  }
Provides some helper functions for resolving and creating SqlType instances that are primitive to the...
static ObjectName Parse(string s)
Parses the given string into a ObjectName object.
Definition: ObjectName.cs:139
Describes the name of an object within a database.
Definition: ObjectName.cs:44
static NumericType TinyInt(int size)

Member Data Documentation

ITable Deveel.Data.Linq.TableQueryTests.table
private

Definition at line 13 of file TableQueryTests.cs.

Property Documentation

QueryContext Deveel.Data.Linq.TableQueryTests.Context
getsetprivate

Definition at line 16 of file TableQueryTests.cs.


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