public void BackupsForSingleProjectExists()
        {
            DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
                                                                                       "Floozy", null, FDOBackendProviderType.kXML);
            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);

            BackupFileRepository repo = new BackupFileRepository();

            Assert.AreEqual(1, repo.AvailableProjectNames.Count());
            Assert.AreEqual(2, repo.GetAvailableVersions("Floozy").Count());
            Assert.AreEqual(backupFileName2, repo.GetBackupFile("Floozy", backupSettings.BackupTime, false).File);
            Assert.AreEqual(backupFileName1, repo.GetMostRecentBackup("Floozy").File);

            Assert.Throws(typeof(KeyNotFoundException), () => repo.GetAvailableVersions("monkey"));
            Assert.Throws(typeof(KeyNotFoundException), () => repo.GetBackupFile("monkey", backupSettings.BackupTime, false));
            Assert.Throws(typeof(KeyNotFoundException), () => repo.GetBackupFile("Floozy", DateTime.MinValue, false));
            Assert.IsNull(repo.GetMostRecentBackup("monkey"));
        }
Example #2
0
        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);
            }
        }
        public void InavlidBackupFile()
        {
            DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
                                                                                       "Floozy", null, FDOBackendProviderType.kXML);
            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);

            BackupFileRepository repo = new BackupFileRepository();
            BackupFileSettings   invalidFileSettings = repo.GetMostRecentBackup("Floozy");
            BackupFileSettings   validFileSettings   = repo.GetBackupFile("Floozy", backupSettings.BackupTime, false);

            ReflectionHelper.SetProperty(validFileSettings, "ProjectName", "Floozy");             // Force it to think it's already loaded and happy.

            Assert.AreEqual(2, repo.GetAvailableVersions("Floozy").Count());
            Assert.IsNull(repo.GetBackupFile("Floozy", invalidFileSettings.BackupTime, true));
            Assert.AreEqual(1, repo.GetAvailableVersions("Floozy").Count());
            Assert.AreEqual(validFileSettings, repo.GetBackupFile("Floozy", validFileSettings.BackupTime, true));
            Assert.AreEqual(1, repo.GetAvailableVersions("Floozy").Count());
        }
		public void Initialize()
		{
			m_backupSettings = new DummyBackupProjectSettings(m_testProjectsRoot,
				TestProjectName, null, FDOBackendProviderType.kXML)
			{
				Comment = "Test comment",
			};
			m_backupProjectService = new ProjectBackupService(Cache, m_backupSettings);
		}
 public void Initialize()
 {
     m_backupSettings = new DummyBackupProjectSettings(m_testProjectsRoot,
                                                       TestProjectName, null, FDOBackendProviderType.kXML)
     {
         Comment = "Test comment",
     };
     m_backupProjectService = new ProjectBackupService(Cache, m_backupSettings);
 }
Example #6
0
        public void Initialize()
        {
            m_backupSettings = new DummyBackupProjectSettings(m_testProjectsRoot,
                                                              TestProjectName, m_linkedFilesRootDir, FDOBackendProviderType.kXML)
            {
                Comment = "Test comment",
            };

            SetupCacheToTestAgainst();
            m_backupProjectService = new ProjectBackupService(Cache, m_backupSettings);
        }
		public void Initialize()
		{
			m_backupSettings = new DummyBackupProjectSettings(m_testProjectsRoot,
				TestProjectName, m_linkedFilesRootDir, FDOBackendProviderType.kXML)
			{
				Comment = "Test comment",
			};

			SetupCacheToTestAgainst();
			m_backupProjectService = new ProjectBackupService(Cache, m_backupSettings);
		}
        public void BackupHasOldStyleDatetimeFormat()
        {
            DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
                                                                                       "Floozy", null, FDOBackendProviderType.kXML);
            string backupFileName1 = Path.Combine(DirectoryFinder.DefaultBackupDirectory,
                                                  Path.ChangeExtension("Floozy 2010-8-21-0506", FwFileExtensions.ksFwBackupFileExtension));

            m_fileOs.AddExistingFile(backupFileName1);

            BackupFileRepository repo = new BackupFileRepository();

            Assert.AreEqual(1, repo.AvailableProjectNames.Count());
            Assert.AreEqual(1, repo.GetAvailableVersions("Floozy").Count());
            Assert.AreEqual(backupFileName1, repo.GetMostRecentBackup("Floozy").File);
        }
Example #9
0
        public void BackupProjectSettings_Values()
        {
            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")
            };

            Assert.AreEqual("Test comment", backupSettings.Comment);
            Assert.IsTrue(backupSettings.IncludeSupportingFiles);
            Assert.IsTrue(backupSettings.IncludeSpellCheckAdditions);
            Assert.AreEqual("FieldWorksLanguageProject", backupSettings.ProjectName);
            Assert.AreEqual(Path.Combine("%proj%", "LinkedFiles"), backupSettings.LinkedFilesPath);
        }
		public void BackupsForSingleProjectExists()
		{
			DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
				"Floozy", null, FDOBackendProviderType.kXML);
			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);

			BackupFileRepository repo = new BackupFileRepository(FwDirectoryFinder.DefaultBackupDirectory);
			Assert.AreEqual(1, repo.AvailableProjectNames.Count());
			Assert.AreEqual(2, repo.GetAvailableVersions("Floozy").Count());
			Assert.AreEqual(backupFileName2, repo.GetBackupFile("Floozy", backupSettings.BackupTime, false).File);
			Assert.AreEqual(backupFileName1, repo.GetMostRecentBackup("Floozy").File);

			Assert.Throws(typeof(KeyNotFoundException), () => repo.GetAvailableVersions("monkey"));
			Assert.Throws(typeof(KeyNotFoundException), () => repo.GetBackupFile("monkey", backupSettings.BackupTime, false));
			Assert.Throws(typeof(KeyNotFoundException), () => repo.GetBackupFile("Floozy", DateTime.MinValue, false));
			Assert.IsNull(repo.GetMostRecentBackup("monkey"));
		}
        public void BackupsForMultipleProjects()
        {
            DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
                                                                                       "AAA", null, FDOBackendProviderType.kXML);

            backupSettings.Comment = "thing1";
            string backupFileName1 = backupSettings.ZipFileName;

            m_fileOs.AddExistingFile(backupFileName1);
            backupSettings.ProjectName = "ZZZ";
            backupSettings.Comment     = "thing2";
            string backupFileName2 = backupSettings.ZipFileName;

            m_fileOs.AddExistingFile(backupFileName2);
            // Add another backup for "AAA" that appears to be older
            backupSettings.ProjectName = "AAA";
            backupSettings.Comment     = null;
            backupSettings.BackupTime  = backupSettings.BackupTime.AddHours(-3);
            string backupFileName3 = backupSettings.ZipFileName;

            m_fileOs.AddExistingFile(backupFileName3);

            BackupFileRepository repo = new BackupFileRepository();

            Assert.AreEqual(2, repo.AvailableProjectNames.Count());
            Assert.AreEqual(2, repo.GetAvailableVersions("AAA").Count());
            Assert.AreEqual(1, repo.GetAvailableVersions("ZZZ").Count());
            BackupFileSettings fileSettings = repo.GetBackupFile("AAA", backupSettings.BackupTime, false);

            Assert.AreEqual(backupFileName3, fileSettings.File);
            Assert.AreEqual(string.Empty, fileSettings.Comment);
            fileSettings = repo.GetMostRecentBackup("AAA");
            Assert.AreEqual(backupFileName1, fileSettings.File);
            Assert.AreEqual("thing1", fileSettings.Comment);
            fileSettings = repo.GetMostRecentBackup("ZZZ");
            Assert.AreEqual(backupFileName2, fileSettings.File);
            Assert.AreEqual("thing2", fileSettings.Comment);
        }
		public void BackupFileSettings_SerializationAndDeserialization()
		{
			var backupSettings = new DummyBackupProjectSettings(
				Path.Combine(FwDirectoryFinder.SourceDirectory, "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);
			}
		}
		public void BackupProjectSettings_DefaultValues()
		{
			var settings = new DummyBackupProjectSettings("whatever", "Blah", null, FDOBackendProviderType.kXML);
			Assert.AreEqual(FwDirectoryFinder.DefaultBackupDirectory, settings.DestinationFolder);
		}
		public void InavlidBackupFile()
		{
			DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
				"Floozy", null, FDOBackendProviderType.kXML);
			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);

			BackupFileRepository repo = new BackupFileRepository(FwDirectoryFinder.DefaultBackupDirectory);
			BackupFileSettings invalidFileSettings = repo.GetMostRecentBackup("Floozy");
			BackupFileSettings validFileSettings = repo.GetBackupFile("Floozy", backupSettings.BackupTime, false);
			ReflectionHelper.SetProperty(validFileSettings, "ProjectName", "Floozy"); // Force it to think it's already loaded and happy.

			Assert.AreEqual(2, repo.GetAvailableVersions("Floozy").Count());
			Assert.IsNull(repo.GetBackupFile("Floozy", invalidFileSettings.BackupTime, true));
			Assert.AreEqual(1, repo.GetAvailableVersions("Floozy").Count());
			Assert.AreEqual(validFileSettings, repo.GetBackupFile("Floozy", validFileSettings.BackupTime, true));
			Assert.AreEqual(1, repo.GetAvailableVersions("Floozy").Count());
		}
		public void BackupsForMultipleProjects()
		{
			DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
				"AAA", null, FDOBackendProviderType.kXML);
			backupSettings.Comment = "thing1";
			string backupFileName1 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName1);
			backupSettings.ProjectName = "ZZZ";
			backupSettings.Comment = "thing2";
			string backupFileName2 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName2);
			// Add another backup for "AAA" that appears to be older
			backupSettings.ProjectName = "AAA";
			backupSettings.Comment = null;
			backupSettings.BackupTime = backupSettings.BackupTime.AddHours(-3);
			string backupFileName3 = backupSettings.ZipFileName;
			m_fileOs.AddExistingFile(backupFileName3);

			BackupFileRepository repo = new BackupFileRepository(FwDirectoryFinder.DefaultBackupDirectory);
			Assert.AreEqual(2, repo.AvailableProjectNames.Count());
			Assert.AreEqual(2, repo.GetAvailableVersions("AAA").Count());
			Assert.AreEqual(1, repo.GetAvailableVersions("ZZZ").Count());
			BackupFileSettings fileSettings = repo.GetBackupFile("AAA", backupSettings.BackupTime, false);
			Assert.AreEqual(backupFileName3, fileSettings.File);
			Assert.AreEqual(string.Empty, fileSettings.Comment);
			fileSettings = repo.GetMostRecentBackup("AAA");
			Assert.AreEqual(backupFileName1, fileSettings.File);
			Assert.AreEqual("thing1", fileSettings.Comment);
			fileSettings = repo.GetMostRecentBackup("ZZZ");
			Assert.AreEqual(backupFileName2, fileSettings.File);
			Assert.AreEqual("thing2", fileSettings.Comment);
		}
Example #16
0
        public void BackupProjectSettings_DefaultValues()
        {
            var settings = new DummyBackupProjectSettings("whatever", "Blah", null, FDOBackendProviderType.kXML);

            Assert.AreEqual(DirectoryFinder.DefaultBackupDirectory, settings.DestinationFolder);
        }
		public void BackupHasOldStyleDatetimeFormat()
		{
			DummyBackupProjectSettings backupSettings = new DummyBackupProjectSettings("monkey",
				"Floozy", null, FDOBackendProviderType.kXML);
			string backupFileName1 = Path.Combine(FwDirectoryFinder.DefaultBackupDirectory,
				Path.ChangeExtension("Floozy 2010-8-21-0506", FdoFileHelper.ksFwBackupFileExtension));
			m_fileOs.AddExistingFile(backupFileName1);

			BackupFileRepository repo = new BackupFileRepository(FwDirectoryFinder.DefaultBackupDirectory);
			Assert.AreEqual(1, repo.AvailableProjectNames.Count());
			Assert.AreEqual(1, repo.GetAvailableVersions("Floozy").Count());
			Assert.AreEqual(backupFileName1, repo.GetMostRecentBackup("Floozy").File);
		}
		public void BackupProjectSettings_Values()
		{
			var backupSettings = new DummyBackupProjectSettings(
				Path.Combine(FwDirectoryFinder.SourceDirectory, "FDO/FDOTests/BackupRestore"),
				"FieldWorksLanguageProject", null, FDOBackendProviderType.kXML)
				{
					Comment = "Test comment",
					IncludeSupportingFiles = true,
					IncludeSpellCheckAdditions = true,
					LinkedFilesPath = Path.Combine("%proj%", "LinkedFiles")
				};

			Assert.AreEqual("Test comment", backupSettings.Comment);
			Assert.IsTrue(backupSettings.IncludeSupportingFiles);
			Assert.IsTrue(backupSettings.IncludeSpellCheckAdditions);
			Assert.AreEqual("FieldWorksLanguageProject", backupSettings.ProjectName);
			Assert.AreEqual(Path.Combine("%proj%", "LinkedFiles"), backupSettings.LinkedFilesPath);
		}