示例#1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="RestoreProjectDlg"/> class.
 /// </summary>
 /// <param name="defaultProjectName">Default project to show existing backups for.</param>
 /// <param name="helpTopicProvider">The help topic provider.</param>
 /// ------------------------------------------------------------------------------------
 public RestoreProjectDlg(string defaultProjectName,
                          IHelpTopicProvider helpTopicProvider) : this(helpTopicProvider)
 {
     m_presenter = new RestoreProjectPresenter(this, defaultProjectName);
     m_rdoDefaultFolder_CheckedChanged(null, null);
     PopulateProjectList(m_presenter.DefaultProjectName);
 }
		public void VerifyStringForBackupPropertiesLabel()
		{
			var restoreProjectPresenter = new RestoreProjectPresenter(null, string.Empty);
			BackupFileSettings backupSettings = new BackupFileSettings(
				Path.ChangeExtension("dummy", FdoFileHelper.ksFwBackupFileExtension), false);
			// This is needed to thwart BackupFileSettings's normal logic to populate the flags
			// from the backup zip file
			ReflectionHelper.SetField(backupSettings, "m_projectName", "dummy");

			ReflectionHelper.SetField(backupSettings, "m_configurationSettings", true);
			String resultStr = restoreProjectPresenter.IncludesFiles(backupSettings);
			Assert.AreEqual("Configuration settings", resultStr);

			ReflectionHelper.SetField(backupSettings, "m_supportingFiles", true);
			resultStr = restoreProjectPresenter.IncludesFiles(backupSettings);
			Assert.AreEqual("Configuration settings and Supporting Files.", resultStr);

			ReflectionHelper.SetField(backupSettings, "m_configurationSettings", false);
			resultStr = restoreProjectPresenter.IncludesFiles(backupSettings);
			Assert.AreEqual("Supporting Files", resultStr);

			ReflectionHelper.SetField(backupSettings, "m_linkedFiles", true);
			resultStr = restoreProjectPresenter.IncludesFiles(backupSettings);
			Assert.AreEqual("Linked files and Supporting Files.", resultStr);

			ReflectionHelper.SetField(backupSettings, "m_configurationSettings", true);
			resultStr = restoreProjectPresenter.IncludesFiles(backupSettings);
			Assert.AreEqual("Configuration settings, Linked files and Supporting Files.", resultStr);

			ReflectionHelper.SetField(backupSettings, "m_spellCheckAdditions", true);
			resultStr = restoreProjectPresenter.IncludesFiles(backupSettings);
			Assert.AreEqual("Configuration settings, Linked files, Supporting Files and Spelling dictionary.", resultStr);
		}
示例#3
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="RestoreProjectDlg"/> class.
 /// </summary>
 /// <param name="backupFileSettings">Specific backup file settings to use (dialog
 /// controls to select a backup file will be disabled)</param>
 /// <param name="helpTopicProvider">The help topic provider.</param>
 /// ------------------------------------------------------------------------------------
 public RestoreProjectDlg(BackupFileSettings backupFileSettings,
                          IHelpTopicProvider helpTopicProvider) : this(helpTopicProvider)
 {
     m_lblBackupZipFile.Text      = backupFileSettings.File;
     m_presenter                  = new RestoreProjectPresenter(this);
     BackupFileSettings           = backupFileSettings;
     m_rdoDefaultFolder.Enabled   = m_btnBrowse.Enabled = false;
     m_rdoAnotherLocation.Checked = true;
     SetOriginalNameFromSettings();
 }
		public void DefaultBackupFile_NoBackupFilesAvailable()
		{
			m_fileOs.ExistingDirectories.Add(FwDirectoryFinder.DefaultBackupDirectory);
			RestoreProjectPresenter presenter = new RestoreProjectPresenter(null, string.Empty);
			Assert.AreEqual(String.Empty, presenter.DefaultProjectName);
		}
		public void RestoreToName_GetSuggestedNewProjectName()
		{
			// Add three project files, one being a copy of another.
			string proj1 = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "AAA"), "AAA.fwdata");
			m_fileOs.AddExistingFile(proj1);
			string proj2 = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "BBB"), "BBB.fwdata");
			m_fileOs.AddExistingFile(proj2);
			string proj3 = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "AAA-01"), "AAA-01.fwdata");
			m_fileOs.AddExistingFile(proj3);

			BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null, FwDirectoryFinder.DefaultBackupDirectory);
			backupSettings.ProjectName = "AAA";
			string backupFileName1 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName1);
			using (RestoreProjectDlg dlg1 = new RestoreProjectDlg("AAA", "Test", null))
			{
			dlg1.Settings.ProjectName = "AAA";
			RestoreProjectPresenter presenter1 = new RestoreProjectPresenter(dlg1, "AAA");
			string suggestion1 = presenter1.GetSuggestedNewProjectName();
			Assert.AreEqual("AAA-02", suggestion1);
			}

			backupSettings.ProjectName = "BBB";
			string backupFileName2 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName2);
			using (RestoreProjectDlg dlg2 = new RestoreProjectDlg("BBB", "Test", null))
			{
			dlg2.Settings.ProjectName = "BBB";
			RestoreProjectPresenter presenter2 = new RestoreProjectPresenter(dlg2, "BBB");
			string suggestion2 = presenter2.GetSuggestedNewProjectName();
			Assert.AreEqual("BBB-01", suggestion2);
			}

			backupSettings.ProjectName = "CCC";
			string backupFileName3 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName3);
			using (RestoreProjectDlg dlg3 = new RestoreProjectDlg("CCC", "Test", null))
			{
			dlg3.Settings.ProjectName = "CCC";
			RestoreProjectPresenter presenter3 = new RestoreProjectPresenter(dlg3, "CCC");
			string suggestion3 = presenter3.GetSuggestedNewProjectName();
			Assert.AreEqual("CCC-01", suggestion3);
		}
	}
		public void DefaultBackupFile_BackupsForOtherProjectsButNotCurrent()
		{
			BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null, FwDirectoryFinder.DefaultBackupDirectory);
			backupSettings.ProjectName = "AAA";
			string backupFileName1 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName1);
			backupSettings.ProjectName = "ZZZ";
			string backupFileName2 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName2);
			// Add another backup for "AAA" that appears to be older
			backupSettings.ProjectName = "AAA";
			backupSettings.BackupTime = backupSettings.BackupTime.AddHours(-3);
			string backupFileName3 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName3);
			RestoreProjectPresenter presenter = new RestoreProjectPresenter(null, "Current Project");
			Assert.AreEqual("AAA", presenter.DefaultProjectName);
		}
		public void DefaultBackupFile_BackupForCurrentProjectExists()
		{
			BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null, FwDirectoryFinder.DefaultBackupDirectory);
			string backupFileName1 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName1);
			// Force the second backup to appear to be older
			backupSettings.BackupTime = backupSettings.BackupTime.AddHours(-3);
			string backupFileName2 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName2);
			RestoreProjectPresenter presenter = new RestoreProjectPresenter(null, string.Empty);
			Assert.AreEqual(backupSettings.ProjectName, presenter.DefaultProjectName);
		}
示例#8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="RestoreProjectDlg"/> class.
		/// </summary>
		/// <param name="backupFileSettings">Specific backup file settings to use (dialog
		/// controls to select a backup file will be disabled)</param>
		/// <param name="appName">Name of the application (for showing in message box captions).</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public RestoreProjectDlg(BackupFileSettings backupFileSettings, string appName,
			IHelpTopicProvider helpTopicProvider) : this(appName, helpTopicProvider)
		{
			m_lblBackupZipFile.Text = backupFileSettings.File;
			m_presenter = new RestoreProjectPresenter(this);
			BackupFileSettings = backupFileSettings;
			m_rdoDefaultFolder.Enabled = m_btnBrowse.Enabled = false;
			m_rdoAnotherLocation.Checked = true;
			SetOriginalNameFromSettings();
		}
示例#9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="RestoreProjectDlg"/> class.
		/// </summary>
		/// <param name="defaultProjectName">Default project to show existing backups for.</param>
		/// <param name="appName">Name of the application (for showing in message box captions).</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public RestoreProjectDlg(string defaultProjectName, string appName,
			IHelpTopicProvider helpTopicProvider) : this(appName, helpTopicProvider)
		{
			m_presenter = new RestoreProjectPresenter(this, defaultProjectName);
			m_rdoDefaultFolder_CheckedChanged(null, null);
			PopulateProjectList(m_presenter.DefaultProjectName);
		}