@@ -66,39 +66,39 @@ public override void SetUp()
6666 [ Test ]
6767 public void BackupRestoreTest ( )
6868 {
69- var id = Guid . NewGuid ( ) ;
70- BackupRestoreTest_BackupPart ( id ) ;
71- BackupRestoreTest_RestorePart ( id ) ;
72- // test the database was actually restored fine
73- Connection . Open ( ) ;
74- Connection . Close ( ) ;
75- }
76- void BackupRestoreTest_BackupPart ( Guid id )
77- {
78- FbBackup backupSvc = new FbBackup ( ) ;
69+ var backupName = $ "{ Guid . NewGuid ( ) . ToString ( ) } .bak";
70+ void BackupPart ( )
71+ {
72+ FbBackup backupSvc = new FbBackup ( ) ;
7973
80- backupSvc . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
81- backupSvc . Options = FbBackupFlags . IgnoreLimbo ;
82- backupSvc . BackupFiles . Add ( new FbBackupFile ( CreateBackupFilename ( id ) , 2048 ) ) ;
83- backupSvc . Verbose = true ;
74+ backupSvc . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
75+ backupSvc . Options = FbBackupFlags . IgnoreLimbo ;
76+ backupSvc . BackupFiles . Add ( new FbBackupFile ( backupName , 2048 ) ) ;
77+ backupSvc . Verbose = true ;
8478
85- backupSvc . ServiceOutput += new EventHandler < ServiceOutputEventArgs > ( ServiceOutput ) ;
79+ backupSvc . ServiceOutput += new EventHandler < ServiceOutputEventArgs > ( ServiceOutput ) ;
8680
87- backupSvc . Execute ( ) ;
88- }
89- void BackupRestoreTest_RestorePart ( Guid id )
90- {
91- FbRestore restoreSvc = new FbRestore ( ) ;
81+ backupSvc . Execute ( ) ;
82+ }
83+ void RestorePart ( )
84+ {
85+ FbRestore restoreSvc = new FbRestore ( ) ;
9286
93- restoreSvc . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
94- restoreSvc . Options = FbRestoreFlags . Create | FbRestoreFlags . Replace ;
95- restoreSvc . PageSize = TestsSetup . PageSize ;
96- restoreSvc . Verbose = true ;
97- restoreSvc . BackupFiles . Add ( new FbBackupFile ( CreateBackupFilename ( id ) , 2048 ) ) ;
87+ restoreSvc . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
88+ restoreSvc . Options = FbRestoreFlags . Create | FbRestoreFlags . Replace ;
89+ restoreSvc . PageSize = TestsSetup . PageSize ;
90+ restoreSvc . Verbose = true ;
91+ restoreSvc . BackupFiles . Add ( new FbBackupFile ( backupName , 2048 ) ) ;
9892
99- restoreSvc . ServiceOutput += new EventHandler < ServiceOutputEventArgs > ( ServiceOutput ) ;
93+ restoreSvc . ServiceOutput += new EventHandler < ServiceOutputEventArgs > ( ServiceOutput ) ;
10094
101- restoreSvc . Execute ( ) ;
95+ restoreSvc . Execute ( ) ;
96+ }
97+ BackupPart ( ) ;
98+ RestorePart ( ) ;
99+ // test the database was actually restored fine
100+ Connection . Open ( ) ;
101+ Connection . Close ( ) ;
102102 }
103103
104104 [ TestCase ( true ) ]
@@ -346,42 +346,45 @@ public void NBackupBackupRestoreTest()
346346 if ( ! EnsureVersion ( new Version ( "2.5.0.0" ) ) )
347347 return ;
348348
349- var id = Guid . NewGuid ( ) ;
350- NBackupBackupRestoreTest_BackupPart ( id ) ;
351- NBackupBackupRestoreTest_RestorePart ( id ) ;
352- }
353- void NBackupBackupRestoreTest_BackupPart ( Guid id )
354- {
355- Action < int > doLevel = l =>
349+ const int Levels = 2 ;
350+ var backupName = $ "{ Guid . NewGuid ( ) . ToString ( ) } .nbak";
351+ void BackupPart ( )
356352 {
357- var nbak = new FbNBackup ( ) ;
353+ void DoLevel ( int level )
354+ {
355+ var nbak = new FbNBackup ( ) ;
358356
359- nbak . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
360- nbak . Level = l ;
361- nbak . BackupFile = CreateBackupFilename ( id ) + l . ToString ( ) ;
362- nbak . DirectIO = true ;
363- nbak . Options = FbNBackupFlags . NoDatabaseTriggers ;
357+ nbak . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
358+ nbak . Level = level ;
359+ nbak . BackupFile = backupName + level . ToString ( ) ;
360+ nbak . DirectIO = true ;
361+ nbak . Options = FbNBackupFlags . NoDatabaseTriggers ;
364362
365- nbak . ServiceOutput += ServiceOutput ;
363+ nbak . ServiceOutput += ServiceOutput ;
366364
367- nbak . Execute ( ) ;
368- } ;
369- doLevel ( 0 ) ;
370- doLevel ( 1 ) ;
371- }
372- void NBackupBackupRestoreTest_RestorePart ( Guid id )
373- {
374- FbConnection . DropDatabase ( BuildConnectionString ( FbServerType , Compression ) ) ;
365+ nbak . Execute ( ) ;
366+ }
367+ for ( int i = 0 ; i < Levels ; i ++ )
368+ {
369+ DoLevel ( i ) ;
370+ }
371+ }
372+ void RestorePart ( )
373+ {
374+ FbConnection . DropDatabase ( BuildConnectionString ( FbServerType , Compression ) ) ;
375375
376- var nrest = new FbNRestore ( ) ;
376+ var nrest = new FbNRestore ( ) ;
377377
378- nrest . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
379- nrest . BackupFiles = Enumerable . Range ( 0 , 2 ) . Select ( l => CreateBackupFilename ( id ) + l . ToString ( ) ) ;
380- nrest . DirectIO = true ;
378+ nrest . ConnectionString = BuildServicesConnectionString ( FbServerType , Compression , true ) ;
379+ nrest . BackupFiles = Enumerable . Range ( 0 , Levels ) . Select ( l => backupName + l . ToString ( ) ) ;
380+ nrest . DirectIO = true ;
381381
382- nrest . ServiceOutput += ServiceOutput ;
382+ nrest . ServiceOutput += ServiceOutput ;
383383
384- nrest . Execute ( ) ;
384+ nrest . Execute ( ) ;
385+ }
386+ BackupPart ( ) ;
387+ RestorePart ( ) ;
385388 }
386389
387390 [ Test ]
@@ -427,11 +430,6 @@ void ServiceOutput(object sender, ServiceOutputEventArgs e)
427430 TestContext . WriteLine ( e . Message ) ;
428431 }
429432
430- string CreateBackupFilename ( Guid id )
431- {
432- return $ "{ TestsSetup . Database ( FbServerType , Compression ) } _{ id } .fbk";
433- }
434-
435433 #endregion
436434 }
437435}
0 commit comments