Create() public method

Creates new database with given name.
public Create ( string databaseName ) : AResult
databaseName string
return AResult
        public void Should_fail_create_already_existing_database()
        {
            Database.CleanupTestDatabases();

            var db = new ADatabase(Database.SystemAlias);

            var createResult = db.Create(Database.TestDatabaseGeneral);

            var createResult2 = db.Create(Database.TestDatabaseGeneral);

            Assert.AreEqual(409, createResult2.StatusCode);
            Assert.IsFalse(createResult2.Success);
            Assert.IsTrue(createResult2.HasValue);
            Assert.IsFalse(createResult2.Value);
            Assert.IsNotNull(createResult2.Error);
        }
        public void Should_create_database()
        {
            Database.CleanupTestDatabases();

            var db = new ADatabase(Database.SystemAlias);

            var createResult = db.Create(Database.TestDatabaseOneTime);

            Assert.AreEqual(201, createResult.StatusCode);
            Assert.IsTrue(createResult.Success);
            Assert.IsTrue(createResult.HasValue);
            Assert.IsTrue(createResult.Value);
        }
        public void Should_delete_database()
        {
            Database.CleanupTestDatabases();

            var db = new ADatabase(Database.SystemAlias);

            var createResult = db.Create(Database.TestDatabaseGeneral);

            var deleteResult = db.Drop(Database.TestDatabaseGeneral);

            Assert.AreEqual(200, deleteResult.StatusCode);
            Assert.IsTrue(deleteResult.Success);
            Assert.IsTrue(deleteResult.HasValue);
            Assert.IsTrue(deleteResult.Value);
        }
        public void Should_create_database_with_users()
        {
            Database.CleanupTestDatabases();

            var db = new ADatabase(Database.SystemAlias);

            var users = new List<AUser>()
            {
                new AUser { Username = "******", Password = "******", Active = true },
                new AUser { Username = "******", Password = "******", Active = false }
            };

            var createResult = db.Create(Database.TestDatabaseOneTime, users);

            Assert.AreEqual(201, createResult.StatusCode);
            Assert.IsTrue(createResult.Success);
            Assert.IsTrue(createResult.HasValue);
            Assert.IsTrue(createResult.Value);
        }
        public void Should_fail_create_database_from_non_system_database()
        {
            Database.CleanupTestDatabases();

            var db = new ADatabase(Database.SystemAlias);

            var createResult = db.Create(Database.TestDatabaseGeneral);

            var nonSystemDatabase = new ADatabase(Database.Alias);

            var createResult2 = nonSystemDatabase.Create(Database.TestDatabaseOneTime);

            Assert.AreEqual(403, createResult2.StatusCode);
            Assert.IsFalse(createResult2.Success);
            Assert.IsTrue(createResult2.HasValue);
            Assert.IsFalse(createResult2.Value);
            Assert.IsNotNull(createResult2.Error);
        }
        public void Should_get_list_of_all_databases()
        {
            Database.CleanupTestDatabases();

            var db = new ADatabase(Database.SystemAlias);

            var resultCreate = db.Create(Database.TestDatabaseOneTime);

            var resultList = db.GetAllDatabases();

            Assert.AreEqual(200, resultList.StatusCode);
            Assert.IsTrue(resultList.Success);
            Assert.IsTrue(resultList.HasValue);
            Assert.IsTrue(resultList.Value.Contains(Database.TestDatabaseOneTime));
            Assert.IsTrue(resultList.Value.Contains("_system"));
        }
Beispiel #7
0
        public static void CreateTestDatabase(string databaseName)
        {
            DeleteTestDatabase(databaseName);

            var db = new ADatabase(Database.SystemAlias);

            var resultList = db.GetAccessibleDatabases();

            if (resultList.Success && resultList.Value.Contains(databaseName))
            {
                db.Drop(databaseName);
            }

            db.Create(databaseName);
        }