public void RestoreProjectSettings_VerifyExistenceOfProject() { string restoreTestsZipFileDir = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/BackupRestore/RestoreServiceTestsZipFileDir"); RestoreProjectSettings restoreSettings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory) { Backup = new BackupFileSettings(Path.Combine(restoreTestsZipFileDir, Path.ChangeExtension("TestRestoreFWProject", FdoFileHelper.ksFwBackupFileExtension))), IncludeConfigurationSettings = false, IncludeLinkedFiles = false, IncludeSupportingFiles = true, IncludeSpellCheckAdditions = false, ProjectName = "TestRestoreFWProject 01", BackupOfExistingProjectRequested = false, }; ProjectRestoreServiceTests.RemoveAnyFilesAndFoldersCreatedByTests(restoreSettings); ProjectRestoreService restoreProjectService = new ProjectRestoreService(restoreSettings, new DummyFdoUI(), FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe); Assert.False(restoreSettings.ProjectExists, "Project exists but it should not."); try { // Restore the project and check to ensure that it exists. restoreProjectService.RestoreProject(new DummyProgressDlg()); Assert.True(restoreSettings.ProjectExists, "Project does not exist but it should."); } finally { ProjectRestoreServiceTests.RemoveAnyFilesAndFoldersCreatedByTests(restoreSettings); } }
public void RestoreProjectSettings_VerifyExistenceOfHgRepo() { string restoreTestsZipFileDir = Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/BackupRestore/RestoreServiceTestsZipFileDir"); RestoreProjectSettings restoreSettings = new RestoreProjectSettings(FwDirectoryFinder.ProjectsDirectory) { Backup = new BackupFileSettings(Path.Combine(restoreTestsZipFileDir, Path.ChangeExtension("TestRestoreFWProject", FdoFileHelper.ksFwBackupFileExtension))), IncludeConfigurationSettings = false, IncludeLinkedFiles = false, IncludeSupportingFiles = true, IncludeSpellCheckAdditions = false, ProjectName = "TestRestoreFWProject 01", BackupOfExistingProjectRequested = false, }; ProjectRestoreService restoreProjectService = new ProjectRestoreService(restoreSettings, new DummyFdoUI(), FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe); try { // Restore the project and check to ensure that it exists, but is not using Send/Receive. restoreProjectService.RestoreProject(new DummyProgressDlg()); Assert.True(restoreSettings.ProjectExists, "Project does not exist but it should."); Assert.False(restoreSettings.UsingSendReceive, "Project is using S/R but it should not be."); string otherReposDir = Path.Combine(restoreSettings.ProjectPath, FdoFileHelper.OtherRepositories); // Create a non-repository folder in OtherRepositories and verify the project is not using Send/Receive Directory.CreateDirectory(Path.Combine(otherReposDir, "NotARepo_LIFT", "RandomSubdir")); Assert.False(restoreSettings.UsingSendReceive, "Project should not be using S/R if there is no hg repo in OtherRepositories."); // Create a hg repository in OtherRepositories and verify the project is using Send/Receive Directory.CreateDirectory(Path.Combine(otherReposDir, "IsARepo_ButNotNecessarilyLIFT", ".hg")); Assert.True(restoreSettings.UsingSendReceive, "Project should be using S/R if there is a hg repo in OtherRepositories."); Directory.Delete(otherReposDir, true); Assert.False(restoreSettings.UsingSendReceive, "Project should not be using S/R if there is no hg repo. Deletion failed?"); // Make the project directory a hg repo Directory.CreateDirectory(Path.Combine(restoreSettings.ProjectPath, ".hg")); Assert.True(restoreSettings.UsingSendReceive, "Project should be using S/R if the project directory is a hg repo."); } finally { ProjectRestoreServiceTests.RemoveAnyFilesAndFoldersCreatedByTests(restoreSettings); } }