DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
TriggerTests.cs
Go to the documentation of this file.
1 //
2 // Copyright 2010-2014 Deveel
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 using System;
16 
17 using Deveel.Data.Sql.Tables;
18 using Deveel.Data.Types;
19 
20 using NUnit.Framework;
21 
22 namespace Deveel.Data.Sql.Triggers {
23  [TestFixture]
24  public class TriggerTests : ContextBasedTest {
25  private static readonly ObjectName TestTableName = ObjectName.Parse("APP.test_table");
26 
27  protected override IQuery CreateQuery(ISession session) {
28  var query = base.CreateQuery(session);
29  var tableInfo = new TableInfo(TestTableName);
30  tableInfo.AddColumn("id", PrimitiveTypes.Integer());
31  tableInfo.AddColumn("name", PrimitiveTypes.String());
32  tableInfo.AddColumn("date", PrimitiveTypes.DateTime());
33  query.CreateTable(tableInfo);
34  return query;
35  }
36 
37  [Test]
38  public void CreateCallbackTrigger() {
39  var triggerName = ObjectName.Parse("APP.test_trigger");
40  Assert.DoesNotThrow(() => Query.CreateCallbackTrigger(triggerName, TriggerEventType.BeforeInsert));
41 
42  bool exists = false;
43  Assert.DoesNotThrow(() => exists = Query.TriggerExists(triggerName));
44  Assert.IsTrue(exists);
45  }
46 
47  [Test]
48  public void CreateProcedureTrigger() {
49 
50  }
51  }
52 }
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
TriggerEventType
The different types of high layer trigger events.
Describes the name of an object within a database.
Definition: ObjectName.cs:44
An isolated session to a given database for a given user, encapsulating the transaction for operation...
Definition: ISession.cs:30
override IQuery CreateQuery(ISession session)
Definition: TriggerTests.cs:27
Defines the metadata properties of a table existing within a database.
Definition: TableInfo.cs:41