DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
CreateViewTests.cs
Go to the documentation of this file.
1 using System;
2 using System.Linq;
3 
5 
6 using NUnit.Framework;
7 
8 namespace Deveel.Data.Sql.Compile {
9  [TestFixture]
11  [Test]
12  public void WithColumns() {
13  const string sql = "CREATE VIEW test_view (a, b, c) AS SELECT * FROM test";
14 
15  var result = Compile(sql);
16  Assert.IsNotNull(result);
17  Assert.IsFalse(result.HasErrors);
18  Assert.AreEqual(1, result.Statements.Count);
19 
20  var statement = result.Statements.First();
21 
22  Assert.IsInstanceOf<CreateViewStatement>(statement);
23 
24  var createView = (CreateViewStatement) statement;
25  Assert.AreEqual("test_view", createView.ViewName);
26  Assert.IsNotEmpty(createView.ColumnNames);
27  Assert.IsNotNull(createView.QueryExpression);
28  Assert.IsFalse(createView.ReplaceIfExists);
29  }
30 
31  [Test]
32  public void WithoutColumns() {
33  const string sql = "CREATE VIEW test_view AS SELECT a, c FROM test";
34 
35  var result = Compile(sql);
36  Assert.IsNotNull(result);
37  Assert.IsFalse(result.HasErrors);
38  Assert.AreEqual(1, result.Statements.Count);
39 
40  var statement = result.Statements.First();
41 
42  Assert.IsInstanceOf<CreateViewStatement>(statement);
43 
44  var createView = (CreateViewStatement)statement;
45  Assert.AreEqual("test_view", createView.ViewName);
46  Assert.IsNull(createView.ColumnNames);
47  Assert.IsNotNull(createView.QueryExpression);
48  Assert.IsFalse(createView.ReplaceIfExists);
49  }
50  }
51 }