public void DropDatabaseHandlesDatabaseDoesNotExist()
        {
            var filename = Path.Combine(Path.GetTempPath(), _filename);

            _db = new LocalDbDatabase(_databaseName, filename);

            Assert.False(DatabaseExist(_db.MasterConnectionString, _databaseName));

            _db.DropDatabase();
        }
        public void DropDatabaseRemovesDatabaseFromLocalDb()
        {
            var filename = Path.Combine(Path.GetTempPath(), _filename);

            _db = new LocalDbDatabase(_databaseName, filename);

            // Make sure database exists.
            _db.CreateDatabase();
            Assert.True(DatabaseExist(_db.MasterConnectionString, _databaseName));

            _db.DropDatabase();
            Assert.False(DatabaseExist(_db.MasterConnectionString, _databaseName));
        }
        public void DropDatabaseRemovesFilesFromFileSystem()
        {
            var filename = Path.Combine(Path.GetTempPath(), _filename);

            _db = new LocalDbDatabase(_databaseName, filename);

            // Make sure database exists.
            _db.CreateDatabase();
            Assert.True(File.Exists(filename));

            _db.DropDatabase();
            Assert.False(File.Exists(filename));
        }
Beispiel #4
0
        public void DropDatabaseIgnoresErrorsWhenDataFileDoesNotExist()
        {
            var directory = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            Directory.CreateDirectory(directory);

            var filename = Path.Combine(directory, _filename);

            _db = new LocalDbDatabase(_databaseName, filename);

            _db.CreateDatabase();

            // Let the filesystem let go of the file so it isn't in use.
            Thread.Sleep(250);

            Directory.Delete(directory, true);

            _db = new LocalDbDatabase(_databaseName);

            _db.CreateDatabase();
            _db.DropDatabase();
        }
 public void Dispose()
 {
     _db?.DropDatabase();
 }