Example #1
0
        public async Task Database_CreateAndUpdate_UpdatesRunWithoutException()
        {
            // Arrange
            var exampleFile         = "UpdateTest.db";
            var databaseFileHandler = new DatabaseFileHandler(exampleFile);

            databaseFileHandler.DeleteDatabaseIfExists();
            var testInfrastructure = new TestInfrastructure();

            // Act && Assert

            await testInfrastructure.CreateNewUnittestDatabaseAsync(exampleFile);

            databaseFileHandler.DeleteDatabaseIfExists();
        }
Example #2
0
        public void Database_Create_GetsCreated()
        {
            // Arrange
            var exampleFile         = "CreateFileTest.db";
            var databaseFileHandler = new DatabaseFileHandler(exampleFile);

            databaseFileHandler.DeleteDatabaseIfExists();

            // Act && Assert
            var fullexampleFile = Path.Combine(DataDirectories.GetUserApplicationDatabasesDirectory(), exampleFile);

            Assert.DoesNotThrow(() => databaseFileHandler.CreateNewDatabase());

            Assert.That(File.Exists(fullexampleFile));
            databaseFileHandler.DeleteDatabaseIfExists();
        }
Example #3
0
        private DatabaseFileHandler InitializeDatabase(InitializationSettings settings)
        {
            var databaseFileHandler = new DatabaseFileHandler(settings.DatabaseName);

            if (settings.EnforceRecreationOfDatabase || !databaseFileHandler.DatabaseExists())
            {
                databaseFileHandler.DeleteDatabaseIfExists();
                databaseFileHandler.CreateNewDatabase();
            }

            return(databaseFileHandler);
        }
Example #4
0
        public void Database_Create_ConnectionCouldBeEstablished()
        {
            // Arrange
            var exampleFile         = "ConnectionAfterCreateTest.db";
            var databaseFileHandler = new DatabaseFileHandler(exampleFile);

            databaseFileHandler.DeleteDatabaseIfExists();

            // Act && Assert
            var fullexampleFile = Path.Combine(DataDirectories.GetUserApplicationDatabasesDirectory(), exampleFile);

            Assert.DoesNotThrow(() => databaseFileHandler.CreateNewDatabase());
            var fileWasCreated      = File.Exists(fullexampleFile);
            var connectionWasOpened = false;

            using (var connection = databaseFileHandler.OpenConnection())
            {
                connectionWasOpened = connection.State == ConnectionState.Open;
            }

            Assert.That(fileWasCreated);
            Assert.That(connectionWasOpened);
            databaseFileHandler.DeleteDatabaseIfExists();
        }
Example #5
0
        private static void DeleteUnittestDatabase(string databaseName)
        {
            var fileHandler = new DatabaseFileHandler(databaseName);

            fileHandler.DeleteDatabaseIfExists();
        }