public void RemoveStalePaths() { Assert.IsEmpty(_paths); var path1 = Path.Combine(_mruFileFolder, "mru1.tmp"); File.CreateText(path1).Close(); MruFiles.AddNewPath(path1); var path2 = Path.Combine(_mruFileFolder, "mru2.tmp"); File.CreateText(path2).Close(); MruFiles.AddNewPath(path2); Assert.AreEqual(2, _paths.Count); Assert.Contains(path1, _paths); Assert.Contains(path2, _paths); File.Delete(path1); ReflectionHelper.CallMethod(typeof(MruFiles), "RemoveStalePaths", null); Assert.AreEqual(1, _paths.Count); Assert.IsFalse(_paths.Contains(path1)); Assert.Contains(path2, _paths); File.Delete(path2); ReflectionHelper.CallMethod(typeof(MruFiles), "RemoveStalePaths", null); Assert.IsEmpty(_paths); }
public void AddNewPath_AddMoreThanMax() { Assert.IsEmpty(_paths); var path1 = Path.Combine(_mruFileFolder, "mru1.tmp"); File.CreateText(path1).Close(); Assert.IsTrue(MruFiles.AddNewPath(path1)); var path2 = Path.Combine(_mruFileFolder, "mru2.tmp"); File.CreateText(path2).Close(); Assert.IsTrue(MruFiles.AddNewPath(path2)); var path3 = Path.Combine(_mruFileFolder, "mru3.tmp"); File.CreateText(path3).Close(); Assert.IsTrue(MruFiles.AddNewPath(path3)); var path4 = Path.Combine(_mruFileFolder, "mru4.tmp"); File.CreateText(path4).Close(); Assert.IsTrue(MruFiles.AddNewPath(path4)); Assert.AreEqual(3, _paths.Count); Assert.AreEqual(path2, _paths[2]); Assert.AreEqual(path3, _paths[1]); Assert.AreEqual(path4, _paths[0]); }
/// ------------------------------------------------------------------------------------ // public bool CreateNewProject(string prjFolder) // { // int isep = prjFolder.LastIndexOf(Path.DirectorySeparatorChar); // var prjFile = (isep >= 0 ? prjFolder.Substring(isep + 1) : prjFolder) + ".sprj"; // prjFile = prjFile.Replace(" ", string.Empty); // // ProjectSettingsFilePath = Path.Combine(prjFolder, prjFile); // // // Review: do we care if their is already an .sprj file // // in the folder having a different name? // // if (!File.Exists(ProjectSettingsFilePath)) // return false; // Project.CreateAtLocation(ProjectSettingsFilePath); // // var msg = LocalizationManager.LocalizeString( // "WelcomeDialog.ProjectAlreadyExistsMsg", // "A project already exists in the folder '{0}'.", "Dialog Boxes"); // // Utils.MsgBox(string.Format(msg, prjFolder), MessageBoxIcon.Exclamation); // ProjectSettingsFilePath = null; // return false; // } /// ------------------------------------------------------------------------------------ public WelcomeDialogViewModel() { if (!Settings.Default.FirstTimeRun) { return; } // If this is the first time the program has been run, then stuff // the sample project(s) into the MRU list. var path = Path.Combine(Program.CommonAppDataFolder, "Samples"); if (Directory.Exists(path)) { foreach (var sampleProjectFile in Project.GetAllProjectSettingsFiles(path)) { MruFiles.AddNewPath(sampleProjectFile); } Settings.Default.FirstTimeRun = false; } }
public void Latest() { Assert.IsEmpty(_paths); var path1 = Path.Combine(_mruFileFolder, "mru1.tmp"); File.CreateText(path1).Close(); MruFiles.AddNewPath(path1); Assert.AreEqual(path1, MruFiles.Latest); var path2 = Path.Combine(_mruFileFolder, "mru2.tmp"); File.CreateText(path2).Close(); MruFiles.AddNewPath(path2); Assert.AreEqual(path2, MruFiles.Latest); var path3 = Path.Combine(_mruFileFolder, "mru3.tmp"); File.CreateText(path3).Close(); MruFiles.AddNewPath(path3, true); Assert.AreEqual(path2, MruFiles.Latest); }
public void AddNewPath() { Assert.IsEmpty(_paths); var path1 = Path.Combine(_mruFileFolder, "mru1.tmp"); File.CreateText(path1).Close(); Assert.IsTrue(MruFiles.AddNewPath(path1)); Assert.AreEqual(1, _paths.Count); Assert.Contains(path1, _paths); var path2 = Path.Combine(_mruFileFolder, "mru2.tmp"); MruFiles.AddNewPath(path2); Assert.IsFalse(MruFiles.AddNewPath(path2)); Assert.AreEqual(1, _paths.Count); Assert.Contains(path1, _paths); // Readd a path that already exists. Assert.IsTrue(MruFiles.AddNewPath(path1)); Assert.AreEqual(1, _paths.Count); Assert.Contains(path1, _paths); }
public void AddNewNullPath() { MruFiles.AddNewPath(null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// By the time we get here, we know the app. has settled down after loading a project. /// Now that the project has been loaded without crashing, save the project as the /// most recently opened project. xref: SP-186. /// </summary> /// ------------------------------------------------------------------------------------ private static void SaveLastOpenedProjectInMRUList(object sender, EventArgs e) { Application.Idle -= SaveLastOpenedProjectInMRUList; MruFiles.AddNewPath(_pathOfLoadedProjectFile); Settings.Default.Save(); }