DeveelDB  20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
DatabaseTests.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.Store;
18 
19 using NUnit.Framework;
20 
21 namespace Deveel.Data {
22  [TestFixture]
23  public sealed class DatabaseTests {
26 
27  private const string TestDbName = "testdb";
28  private const string TestAdminUser = "SA";
29  private const string TestAdminPass = "123456";
30 
31  [SetUp]
32  public void TestSetup() {
33  var systemBuilder = new SystemBuilder();
34  systemContext = systemBuilder.BuildSystem();
35 
36  var test = TestContext.CurrentContext.Test.Name;
37 
38  if (test != "CreateNew" &&
39  test != "DatabaseNotExists") {
40  var dbConfig = new Configuration.Configuration();
41  dbConfig.SetValue("database.name", TestDbName);
42  database = systemContext.CreateDatabase(dbConfig, TestAdminUser, TestAdminPass);
43  }
44  }
45 
46  [TearDown]
47  public void TearDown() {
48  database = null;
49  }
50 
51  [Test]
52  public void DatabaseNotExists() {
53  Assert.IsFalse(systemContext.DatabaseExists(TestDbName));
54  }
55 
56  [Test]
57  public void CreateNew() {
58  var dbConfig = new Configuration.Configuration();
59  dbConfig.SetValue("database.name", TestDbName);
60  database = systemContext.CreateDatabase(dbConfig, TestAdminUser, TestAdminPass);
61  }
62 
63  [Test]
64  public void AuthenticateAdmin() {
65  Assert.DoesNotThrow(() => database.Authenticate(TestAdminUser, TestAdminPass));
66  }
67  }
68 }
bool DatabaseExists(string databaseName)
IDatabase CreateDatabase(IConfiguration configuration, string adminUser, string adminPassword)
The representation of a single database in the system.
Definition: IDatabase.cs:40