public void BackupFileSettings_SerializationAndDeserialization() { var backupSettings = new DummyBackupProjectSettings( Path.Combine(DirectoryFinder.FwSourceDirectory, "FDO/FDOTests/BackupRestore"), "FieldWorksLanguageProject", null, FDOBackendProviderType.kXML) { Comment = "Test comment", IncludeSupportingFiles = true, IncludeSpellCheckAdditions = true, LinkedFilesPath = Path.Combine("%proj%", "LinkedFiles") }; using (var stream = new MemoryStream()) { BackupFileSettings.SaveToStream(backupSettings, stream); stream.Seek(0, SeekOrigin.Begin); BackupFileSettings restoredSettings = BackupFileSettings.CreateFromStream(stream); Assert.AreEqual(backupSettings.Comment, restoredSettings.Comment); Assert.AreEqual(backupSettings.IncludeConfigurationSettings, restoredSettings.IncludeConfigurationSettings); Assert.AreEqual(backupSettings.IncludeSupportingFiles, restoredSettings.IncludeSupportingFiles); Assert.AreEqual(backupSettings.IncludeSpellCheckAdditions, restoredSettings.IncludeSpellCheckAdditions); Assert.AreEqual(backupSettings.IncludeLinkedFiles, restoredSettings.IncludeLinkedFiles); Assert.AreEqual(backupSettings.ProjectName, restoredSettings.ProjectName); Assert.AreEqual(backupSettings.BackupTime, restoredSettings.BackupTime); Assert.AreEqual(backupSettings.LinkedFilesPath, restoredSettings.LinkedFilesPathRelativePersisted); Assert.AreEqual(backupSettings.LinkedFilesPath, restoredSettings.LinkedFilesPathActualPersisted); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="BackupProjectDlg"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public BackupProjectDlg(LcmCache cache, IHelpTopicProvider helpTopicProvider) : this() { m_cache = cache; m_helpTopicProvider = helpTopicProvider; m_presenter = new BackupProjectPresenter(this, m_cache); //It should only be displayed if the SupportingFiles folder has content. if (!m_presenter.SupportingFilesFolderContainsFiles) { m_supportingFiles.Enabled = false; } DestinationFolder = FwDirectoryFinder.DefaultBackupDirectory; if (File.Exists(m_presenter.PersistanceFilePath)) { // If something bad happens when loading the previous dialog settings (probably just a // pre-7.0 version), just log the error and use the defaults. ExceptionHelper.LogAndIgnoreErrors(() => { //If the dialog settings file does exist then read it in and set the dialog to match //the last values set. using (FileStream fs = new FileStream(m_presenter.PersistanceFilePath, FileMode.Open)) { IBackupSettings backupSettings = BackupFileSettings.CreateFromStream(fs); // Per FWR-2748, we do NOT want to copy a previous comment into the dialog. //Comment = backupSettings.Comment; //Show SupportingFiles, unchecked by default //SupportingFiles = backupSettings.IncludeSupportingFiles; IncludeConfigurationSettings = backupSettings.IncludeConfigurationSettings; IncludeLinkedFiles = backupSettings.IncludeLinkedFiles; } }); } }