public void NameAndPath() { string myProjectFolder = Path.Combine(FwDirectoryFinder.ProjectsDirectory, "My.Project"); ProjectId projId = new ProjectId(FDOBackendProviderType.kXML, "My.Project", null); Assert.AreEqual(Path.Combine(myProjectFolder, FdoFileHelper.GetXmlDataFileName("My.Project")), projId.Path); Assert.AreEqual("My.Project", projId.Name); projId = new ProjectId(FDOBackendProviderType.kDb4oClientServer, "My.Project", null); Assert.AreEqual(Path.Combine(myProjectFolder, FdoFileHelper.GetDb4oDataFileName("My.Project")), projId.Path); Assert.AreEqual("My.Project", projId.Name); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a db4o database file of given name. /// </summary> /// <param name="projectName">the desired name.</param> /// ------------------------------------------------------------------------------------ public void CreateServerFile(string projectName) { string projectDir = Path.Combine(RemotingServer.Directories.ProjectsDirectory, projectName); string newFilename = Path.Combine(projectDir, FdoFileHelper.GetDb4oDataFileName(projectName)); // Ensure directory exists. Directory.CreateDirectory(projectDir); using (FileStream stream = File.Create(newFilename)) stream.Close(); PopulateServerList(); }
public void AssertValid_Invalid_SharedFolderNotFound() { var proj = new ProjectId(FdoFileHelper.GetDb4oDataFileName("monkey"), FwLinkArgs.kLocalHost); try { proj.AssertValid(); Assert.Fail("FwStartupException expected"); } catch (StartupException exception) { Assert.IsTrue(exception.ReportToUser); } }
public void CleanUpNameForType_Default_onlyName() { m_defaultBepType = FDOBackendProviderType.kDb4oClientServer; string expectedPath = Path.Combine(Path.Combine(FwDirectoryFinder.ProjectsDirectory, "ape"), FdoFileHelper.GetDb4oDataFileName("ape")); m_localCsSvcs.Stub(cs => cs.IdForLocalProject("ape")).Return(expectedPath); m_mockFileOs.AddExistingFile(expectedPath); ProjectId proj = new ProjectId("ape", null); Assert.AreEqual(expectedPath, proj.Path); Assert.AreEqual(FDOBackendProviderType.kDb4oClientServer, proj.Type); Assert.IsTrue(proj.IsValid); }
public void CheckProperties() { string expectedProjectDir = Path.Combine(FwDirectoryFinder.ProjectsDirectory, "SomeTest"); m_mockFileOs.ExistingDirectories.Add(expectedProjectDir); const string type = "db4ocs"; const string host = "127.0.0.1"; string filename = FdoFileHelper.GetDb4oDataFileName("SomeTest"); var proj = new ProjectId(type, filename, host); proj.AssertValid(); Assert.AreEqual(Path.Combine(expectedProjectDir, filename), proj.Path); proj = new ProjectId(filename, host); proj.AssertValid(); Assert.AreEqual(Path.Combine(expectedProjectDir, filename), proj.Path); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Searches the host for any projects. /// Any projects found fire the projectFoundCallback delegate. /// Any exception that is thrown is passed to the exceptionCallback delegate. /// </summary> /// ------------------------------------------------------------------------------------ private void FindProjects() { try { // if we were asked to (typically host is our local machine) show fwdata files. if (m_fShowLocalProjects) { // search sub dirs string[] dirs = Directory.GetDirectories(m_projectsDir); foreach (string dir in dirs) { string file = Path.Combine(dir, FdoFileHelper.GetXmlDataFileName(Path.GetFileName(dir))); if (FileUtils.SimilarFileExists(file)) { m_projectFoundCallback(file); } else { string db4oFile = Path.Combine(dir, FdoFileHelper.GetDb4oDataFileName(Path.GetFileName(dir))); //If the db4o file exists it will be added to the list later and therefore we do not want to //show the .bak file to the user in the open project dialog if (!FileUtils.SimilarFileExists(db4oFile)) { // See if there is a .bak file string backupFile = Path.ChangeExtension(file, FdoFileHelper.ksFwDataFallbackFileExtension); //NOTE: RickM I think this probably should be changed to TrySimilarFileExists but don't want to try this //on a release build. if (FileUtils.SimilarFileExists(backupFile)) { m_projectFoundCallback(backupFile); } } } if (m_forceStop) { return; } } if (!ClientServerServices.Current.Local.ShareMyProjects) { return; } } // if host is not local machine OR ShareMyProjects is true show client server files. foreach (string fullServerPath in ClientServerServices.Current.ProjectNames(m_host, true)) { // The current strategy for handling directory seperator chars in a system where // client and servers are different platforms is to convert seperator chars back and // forth when crossing the platform boundary. string adjustedfullServerPath = fullServerPath.Replace(MiscUtils.IsUnix ? @"\" : @"/", Path.DirectorySeparatorChar.ToString()); m_projectFoundCallback(adjustedfullServerPath); if (m_forceStop) { return; } } } catch (Exception e) { if (m_exceptionCallback != null) { m_exceptionCallback(e); } } if (!m_forceStop && m_onCompletedCallback != null) { m_onCompletedCallback(); } }