public void PortAllBEPsTestsUsingAnUnopenedSource( [Values(FDOBackendProviderType.kXML, FDOBackendProviderType.kDb4oClientServer)] FDOBackendProviderType sourceType, [Values(FDOBackendProviderType.kXML, FDOBackendProviderType.kDb4oClientServer, FDOBackendProviderType.kMemoryOnly)] FDOBackendProviderType targetType) { var path = Path.Combine(Path.GetTempPath(), "FieldWorksTest"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var sourceBackendStartupParameters = GenerateBackendStartupParameters(false, sourceType); var targetBackendStartupParameters = GenerateBackendStartupParameters(true, targetType); var sourceGuids = new List <Guid>(); // Make sure we start from a clean slate DeleteDatabase(sourceBackendStartupParameters); DeleteDatabase(targetBackendStartupParameters); // Set up data source var projId = new TestProjectId(sourceBackendStartupParameters.ProjectId.Type, sourceBackendStartupParameters.ProjectId.Path); using (FdoCache sourceCache = FdoCache.CreateCacheWithNewBlankLangProj( projId, "en", "fr", "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, new FdoSettings())) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var sourceDataSetup = GetMainBEPInterface(sourceCache); sourceCache.ServiceLocator.GetInstance <IUndoStackManager>().Save(); // persist the new db so we can reopen it. sourceDataSetup.LoadDomain(BackendBulkLoadDomain.All); sourceGuids.AddRange(GetAllCmObjects(sourceCache).Select(obj => obj.Guid)); // Collect all source Guids } // Migrate source data to new BEP. IThreadedProgress progressDlg = new DummyProgressDlg(); using (var targetCache = FdoCache.CreateCacheWithNoLangProj( new TestProjectId(targetBackendStartupParameters.ProjectId.Type, null), "en", new DummyFdoUI(), FwDirectoryFinder.FdoDirectories, new FdoSettings())) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var targetDataSetup = GetMainBEPInterface(targetCache); targetDataSetup.InitializeFromSource(new TestProjectId(targetBackendStartupParameters.ProjectId.Type, targetBackendStartupParameters.ProjectId.Path), sourceBackendStartupParameters, "en", progressDlg); targetDataSetup.LoadDomain(BackendBulkLoadDomain.All); CompareResults(sourceGuids, targetCache); } sourceGuids.Clear(); // Try to clean up after ourselves DeleteDatabase(sourceBackendStartupParameters, false); DeleteDatabase(targetBackendStartupParameters, false); }
public void RestoreProject_OverwriteOnlyDataRestored() { IThreadedProgress progressDlg = new DummyProgressDlg(); m_restoreSettings.IncludeConfigurationSettings = false; RemoveAnyFilesAndFoldersCreatedByTests(m_restoreSettings); m_restoreProjectService = new ProjectRestoreService(m_restoreSettings); //Restore the project once and do not delete it so that we can restore the project over the previous one. m_restoreProjectService.RestoreProject(progressDlg); string restoreProjectDirectory = m_restoreSettings.ProjectPath; VerifyFileExists(restoreProjectDirectory, DirectoryFinder.GetXmlDataFileName("TestRestoreFWProject")); var dateTimeTicksOfFirstFile = GetLastWriteTimeOfRestoredFile(restoreProjectDirectory, DirectoryFinder.GetXmlDataFileName("TestRestoreFWProject")); // Linux filesystem modification time precision can be to the second, so wait a moment. if (MiscUtils.IsUnix) { Thread.Sleep(1000); } //Verify that the restoreProjectService indicates that the project already exists. The restoreProjectPresenter //can then inform the user that the project already exists on disk and gives them the chance to backup before //overwriting it. Assert.True(m_restoreSettings.ProjectExists, "Project does not exist but it should."); //Now do another restore then verify that the two files are not the same by comparing the LastWriteTime values. m_restoreProjectService.RestoreProject(progressDlg); var dateTimeTicksOfSecondFile = GetLastWriteTimeOfRestoredFile(restoreProjectDirectory, DirectoryFinder.GetXmlDataFileName("TestRestoreFWProject")); Assert.True(dateTimeTicksOfSecondFile.Equals(dateTimeTicksOfFirstFile), "The dates and times of the files should be the same since they are set to the timestamp of the file in the zip file."); VerifyManditoryFilesUnzippedAndDeleteThem(); RemoveAnyFilesAndFoldersCreatedByTests(m_restoreSettings); RemotingServer.Stop(); }
public void RestoreProject_OverwriteOnlyDataRestored() { IThreadedProgress progressDlg = new DummyProgressDlg(); m_restoreSettings.IncludeConfigurationSettings = false; m_restoreProjectService = new ProjectRestoreService(m_restoreSettings, new DummyFdoUI(), FwDirectoryFinder.ConverterConsoleExe, FwDirectoryFinder.DbExe); //Restore the project once and do not delete it so that we can restore the project over the previous one. m_restoreProjectService.RestoreProject(progressDlg); string restoreProjectDirectory = m_restoreSettings.ProjectPath; VerifyFileExists(restoreProjectDirectory, FdoFileHelper.GetXmlDataFileName("TestRestoreFWProject")); var dateTimeTicksOfFirstFile = GetLastWriteTimeOfRestoredFile(restoreProjectDirectory, FdoFileHelper.GetXmlDataFileName("TestRestoreFWProject")); // Linux filesystem modification time precision can be to the second, so wait a moment. if (MiscUtils.IsUnix) Thread.Sleep(1000); //Verify that the restoreProjectService indicates that the project already exists. The restoreProjectPresenter //can then inform the user that the project already exists on disk and gives them the chance to backup before //overwriting it. Assert.True(m_restoreSettings.ProjectExists, "Project does not exist but it should."); //Now do another restore then verify that the two files are not the same by comparing the LastWriteTime values. m_restoreProjectService.RestoreProject(progressDlg); var dateTimeTicksOfSecondFile = GetLastWriteTimeOfRestoredFile(restoreProjectDirectory, FdoFileHelper.GetXmlDataFileName("TestRestoreFWProject")); Assert.True(dateTimeTicksOfSecondFile.Equals(dateTimeTicksOfFirstFile), "The dates and times of the files should be the same since they are set to the timestamp of the file in the zip file."); VerifyManditoryFilesUnzippedAndDeleteThem(); RemotingServer.Stop(); }
public void PortAllBEPsTestsUsingAnUnopenedSource() { var path = Path.Combine(Path.GetTempPath(), "FieldWorksTest"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } foreach (var sourceBackendStartupParameters in m_sourceInfo) { if (sourceBackendStartupParameters == null) { continue; } // The Memory only source BEP can't tested here, since it can't be deleted, created, and restarted // which is required of all source BEPs in this test. // The source memory BEP is tested in 'PortAllBEPsTestsUsingAnAlreadyOpenedSource', // since source BEPs are only created once and the open connection is reused for all targets. if (sourceBackendStartupParameters.ProjectId.Type == FDOBackendProviderType.kMemoryOnly) { continue; } DeleteDatabase(sourceBackendStartupParameters); var createSource = true; var sourceGuids = new List <Guid>(); foreach (var targetBackendStartupParameters in m_targetInfo) { if (targetBackendStartupParameters == null) { continue; } DeleteDatabase(targetBackendStartupParameters); if (createSource) // When 'createSource' is true, the source is created ex-nihilo. { DeleteDatabase(sourceBackendStartupParameters); } // Set up data source, but only do it once. TestProjectId projId = new TestProjectId(sourceBackendStartupParameters.ProjectId.Type, sourceBackendStartupParameters.ProjectId.Path); IThreadedProgress progressDlg = new DummyProgressDlg(); using (FdoCache sourceCache = createSource ? FdoCache.CreateCacheWithNewBlankLangProj( projId, "en", "fr", "en", progressDlg.ThreadHelper) : FdoCache.CreateCacheFromExistingData(projId, "en", progressDlg)) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var sourceDataSetup = GetMainBEPInterface(sourceCache); if (createSource) { sourceCache.ServiceLocator.GetInstance <IUndoStackManager>().Save(); // persist the new db so we can reopen it. createSource = false; // Next time, only load it. } sourceDataSetup.LoadDomain(BackendBulkLoadDomain.All); foreach (var obj in GetAllCmObjects(sourceCache)) { sourceGuids.Add(obj.Guid); // Collect up all source Guids. } } // Migrate source data to new BEP. using (var targetCache = FdoCache.CreateCacheWithNoLangProj( new TestProjectId(targetBackendStartupParameters.ProjectId.Type, null), "en", progressDlg.ThreadHelper)) { // BEP is a singleton, so we shouldn't call Dispose on it. This will be done // by service locator. var targetDataSetup = GetMainBEPInterface(targetCache); targetDataSetup.InitializeFromSource(new TestProjectId(targetBackendStartupParameters.ProjectId.Type, targetBackendStartupParameters.ProjectId.Path), sourceBackendStartupParameters, "en", progressDlg); targetDataSetup.LoadDomain(BackendBulkLoadDomain.All); CompareResults(sourceGuids, targetCache); } sourceGuids.Clear(); } } }
public void ConvertLexEntryTypes() { var variantEntryTypes = Cache.LangProject.LexDbOA.VariantEntryTypesOA; Assert.That(variantEntryTypes, Is.Not.Null); Assert.That(variantEntryTypes, Is.EqualTo(Cache.LangProject.LexDbOA.VariantEntryTypesOA), "should not make a new one each time!"); Assert.That(variantEntryTypes.PossibilitiesOS.Count, Is.EqualTo(6)); var leitFactory = Cache.ServiceLocator.GetInstance<ILexEntryInflTypeFactory>(); var lexEntryInflType1 = variantEntryTypes.PossibilitiesOS[3] as ILexEntryInflType; var lexEntryInflType2 = variantEntryTypes.PossibilitiesOS[4] as ILexEntryInflType; var lexEntryInflType1Sub1 = leitFactory.Create(); lexEntryInflType1.SubPossibilitiesOS.Insert(0, lexEntryInflType1Sub1); var leFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>(); var lerFactory = Cache.ServiceLocator.GetInstance<ILexEntryRefFactory>(); var entry1 = leFactory.Create(); var ler1 = lerFactory.Create(); entry1.EntryRefsOS.Add(ler1); ler1.VariantEntryTypesRS.Add(lexEntryInflType1); ler1.VariantEntryTypesRS.Add(lexEntryInflType2); var entry2 = leFactory.Create(); var ler2 = lerFactory.Create(); entry2.EntryRefsOS.Add(ler2); ler2.VariantEntryTypesRS.Add(lexEntryInflType1); var progressBar = new DummyProgressDlg(); var itemsToChange = new List<ILexEntryType>(); itemsToChange.Add(lexEntryInflType1); itemsToChange.Add(lexEntryInflType1Sub1); Cache.LangProject.LexDbOA.ConvertLexEntryTypes(progressBar, itemsToChange); var let1 = ler1.VariantEntryTypesRS[0]; Assert.AreEqual(LexEntryTypeTags.kClassId, let1.ClassID, "first lex entry type of first entry should be variant"); let1 = ler1.VariantEntryTypesRS[1]; Assert.AreEqual(LexEntryInflTypeTags.kClassId, let1.ClassID, "second lex entry type of first entry should be irregularly inflected form"); let1 = ler2.VariantEntryTypesRS[0]; Assert.AreEqual(LexEntryTypeTags.kClassId, let1.ClassID, "first lex entry type of second entry should be variant"); variantEntryTypes = Cache.LangProject.LexDbOA.VariantEntryTypesOA; Assert.That(variantEntryTypes, Is.Not.Null); Assert.That(variantEntryTypes, Is.EqualTo(Cache.LangProject.LexDbOA.VariantEntryTypesOA), "should not make a new one each time!"); Assert.That(variantEntryTypes.PossibilitiesOS.Count, Is.EqualTo(6)); var lexEntryType1 = variantEntryTypes.PossibilitiesOS[3] as ILexEntryType; Assert.AreEqual(LexEntryTypeTags.kClassId, lexEntryType1.ClassID, "third type should be variant"); var lexEntryType1Sub1 = lexEntryType1.SubPossibilitiesOS[0] as ILexEntryType; Assert.AreEqual(LexEntryTypeTags.kClassId, lexEntryType1Sub1.ClassID, "third's first type should be variant"); }