Settings that specify how to back up a project. Passed to the backup project presenter to initialize it and the dialog, and also passed to the backup service.
        public void RestoreToName_GetSuggestedNewProjectName()
        {
            // Add three project files, one being a copy of another.
            string proj1 = Path.Combine(Path.Combine(DirectoryFinder.ProjectsDirectory, "AAA"), "AAA.fwdata");

            m_fileOs.AddExistingFile(proj1);
            string proj2 = Path.Combine(Path.Combine(DirectoryFinder.ProjectsDirectory, "BBB"), "BBB.fwdata");

            m_fileOs.AddExistingFile(proj2);
            string proj3 = Path.Combine(Path.Combine(DirectoryFinder.ProjectsDirectory, "AAA-01"), "AAA-01.fwdata");

            m_fileOs.AddExistingFile(proj3);

            BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null);

            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_BackupForCurrentProjectExists()
        {
            BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null);
            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);
        }
        public void DefaultBackupFile_BackupsForOtherProjectsButNotCurrent()
        {
            BackupProjectSettings backupSettings = new BackupProjectSettings(Cache, null);

            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);
        }