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"));
        }
        public void ImportProjectIsAccessible_Paratext6()
        {
            IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create();

            Cache.LanguageProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings);
            importSettings.ImportTypeEnum = TypeOfImport.Paratext6;

            var fileOs = new MockFileOS();
            MockParatextHelper ptHelper = null;
            var saveScriptureProvider   = ScriptureProvider._scriptureProvider;

            ScriptureProvider._scriptureProvider = new MockScriptureProvider();
            try
            {
                FileUtils.Manager.SetFileAdapter(fileOs);
                ptHelper = new MockParatextHelper();
                ParatextHelper.Manager.SetParatextHelperAdapter(ptHelper);
                string paratextDir = ScriptureProvider.SettingsDirectory;
                Assert.NotNull(paratextDir, "Setup problem - ProjectsDirectory should not be null.");
                ptHelper.AddProject("TEV", null, null, true, false, "100001");

                fileOs.AddExistingFile(Path.Combine(paratextDir, "TEV.ssf"));

                importSettings.ParatextScrProj = "KAM";
                importSettings.ParatextBTProj  = "TEV";

                StringCollection projectsNotFound;
                Assert.IsFalse(importSettings.ImportProjectIsAccessible(out projectsNotFound));
                Assert.AreEqual(1, projectsNotFound.Count);
                Assert.AreEqual("KAM", projectsNotFound[0]);

                fileOs.AddExistingFile(Path.Combine(paratextDir, "KAM.ssf"));
                ptHelper.AddProject("KAM", null, null, true, false, "000101");
                Assert.IsTrue(importSettings.ImportProjectIsAccessible(out projectsNotFound));
            }
            finally
            {
                ParatextHelper.Manager.Reset();
                if (ptHelper != null)
                {
                    ptHelper.Dispose();
                }
                FileUtils.Manager.Reset();
                ScriptureProvider._scriptureProvider = saveScriptureProvider;
            }
        }
        public void CreateShortcut_CreateProjectLauncher_AlreadyExists_AnotherCreated()
        {
            m_fileOs.AddExistingFile(m_expectedPathDesktop);
            var tail         = "-2";
            var expectedPath = Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Desktop),
                m_projectName + tail + m_pathExtension);

            Assert.That(FileUtils.SimilarFileExists(expectedPath), Is.False,
                        "Launcher shouldn't exist yet.");

            AssertCreateProjectLauncherWorks(expectedPath);
        }
        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);
        }
Exemplo n.º 5
0
        public void IsValid_NullType()
        {
            const string sProjectName = "monkey";
            string       sFile        = DirectoryFinder.GetXmlDataFileName(sProjectName);

            m_mockFileOs.AddExistingFile(GetXmlProjectFilename(sProjectName));
            ProjectId proj = new ProjectId(null, sFile, null);

            Assert.AreEqual(FDOBackendProviderType.kXML, proj.Type);
            Assert.IsTrue(proj.IsValid);
        }