private void MoveToMissingFolder(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("MoveToMissingFolder", projectType, PropertyGroup( Property("ProjectView", "ShowAllFiles") ), ItemGroup( Folder("Fob", isExcluded: false, isMissing: true), Compile("codefile", isExcluded: false) ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.FindItem("MoveToMissingFolder", "Fob"), solution.FindItem("MoveToMissingFolder", "codefile" + projectType.CodeExtension) ); solution.AssertFileDoesntExist("MoveToMissingFolder", "codefile" + projectType.CodeExtension); solution.AssertFileExists("MoveToMissingFolder", "Fob", "codefile" + projectType.CodeExtension); } } }
public void CutRenamePaste() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("CutRenamePaste"), Compile("CutRenamePaste\\CutRenamePaste") ) ); using (var solution = testDef.Generate().ToMockVs()) { var project = solution.WaitForItem("DragDropCopyCutPaste"); var file = solution.WaitForItem("DragDropCopyCutPaste", "CutRenamePaste", "CutRenamePaste" + projectType.CodeExtension); file.Select(); solution.ControlX(); file.Select(); solution.Type(Key.F2); solution.Type("CutRenamePasteNewName"); solution.Type(Key.Enter); solution.Sleep(1000); project.Select(); solution.ControlV(); solution.CheckMessageBox("The source URL 'CutRenamePaste" + projectType.CodeExtension + "' could not be found."); } } }
// Currently Fails: https://pytools.codeplex.com/workitem/2609 public void MoveFolderWithItem() { using (var app = new VisualStudioApp()) { // close any projects before switching source control... app.Dte.Solution.Close(); app.SelectSourceControlProvider("Test Source Provider"); ExpectSourceControl(); foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("SourceControl", projectType, PropertyGroup( Property("SccProjectName", "HelloWorld"), Property("SccLocalPath", "LocalPath"), Property("SccAuxPath", "AuxPath"), Property("SccProvider", "TestProvider") ), ItemGroup( Folder("Fob"), Folder("Fob\\Oar"), Compile("Program"), Compile("Fob\\Oar\\Quox") ) ); using (var solution = testDef.Generate()) { TestSccProvider.DocumentEvents.Clear(); var project = app.OpenProject(solution.Filename); var window = app.OpenSolutionExplorer(); var folder = window.WaitForItem("Solution 'SourceControl' (1 project)", "SourceControl", "Fob", "Oar"); var point = folder.GetClickablePoint(); Mouse.MoveTo(point); Mouse.Down(MouseButton.Left); var destFolder = window.WaitForItem("Solution 'SourceControl' (1 project)", "SourceControl"); Mouse.MoveTo(destFolder.GetClickablePoint()); Mouse.Up(MouseButton.Left); window.AssertFileExists(Path.GetDirectoryName(solution.Filename), "Solution 'SourceControl' (1 project)", "SourceControl", "Oar", "Quox" + projectType.CodeExtension); var projectDir = Path.GetDirectoryName(project.FullName); AssertDocumentEvents(projectDir, OnQueryRenameFiles(projectType.Code("Fob\\Oar\\Quox"), projectType.Code("Oar\\Quox"), VSQUERYRENAMEFILEFLAGS_NoFlags), OnQueryRenameFiles("Fob\\Oar\\", "Oar", VSQUERYRENAMEFILEFLAGS_Directory), OnAfterRenameFiles(projectType.Code("Fob\\Oar\\Quox"), projectType.Code("Oar\\Quox"), VSRENAMEFILEFLAGS_NoFlags), OnAfterRenameFiles("Fob\\Oar\\", "Oar", VSRENAMEFILEFLAGS_Directory) ); } } } }
public void RunWithoutStartupFile() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("RunWithoutStartupFile", projectType); using (var solution = testDef.Generate().ToVs()) { solution.OpenDialogWithDteExecuteCommand("Debug.Start"); solution.CheckMessageBox("startup file"); solution.OpenDialogWithDteExecuteCommand("Debug.StartWithoutDebugging"); solution.CheckMessageBox("startup file"); } } }
/// <summary> /// Cut item, paste into folder, paste into top-level, 2nd paste should prompt for overwrite /// </summary> private void MultiPaste(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("HelloWorld", projectType, ItemGroup( Compile("server"), Compile("server2"), Folder("SubFolder") ) ); using (var solution = testDef.Generate().ToVs()) { var server = solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension); var server2 = solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension); mover( solution, solution.WaitForItem("HelloWorld", "SubFolder"), solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension), solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension) ); // paste once, multiple items should be pasted Assert.IsNotNull(solution.WaitForItem("HelloWorld", "SubFolder", "server" + projectType.CodeExtension)); Assert.IsNotNull(solution.WaitForItem("HelloWorld", "SubFolder", "server2" + projectType.CodeExtension)); solution.SelectSolutionNode(); mover( solution, solution.WaitForItem("HelloWorld", "SubFolder"), solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension), solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension) ); // paste again, we should get the replace prompts... using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.Cancel(); } // https://pytools.codeplex.com/workitem/1154 // and we shouldn't get a second dialog after cancelling... solution.WaitForDialogDismissed(); } } }
public void ShowAllFilesToggle() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFiles", projectType, Folder("SubFolder"), Compile("SubFolder\\server"), Property("ProjectView", "ProjectFiles") ); using (var solution = def.Generate().ToVs()) { var projectNode = solution.WaitForItem("ShowAllFiles", "SubFolder", "server" + projectType.CodeExtension); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all Assert.IsTrue(solution.GetProject("ShowAllFiles").GetIsFolderExpanded("SubFolder")); } } }
public void CopiedBeforeDragPastedAfterDrop() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Compile("CopiedBeforeDragPastedAfterDrop"), Compile("DragAndDroppedDuringCopy"), Folder("DragDuringCopyDestination"), Folder("PasteFolder") ) ); using (var solution = testDef.Generate().ToVs()) { var project = solution.WaitForItem("DragDropCopyCutPaste"); Assert.AreNotEqual(null, project); var file = solution.WaitForItem("DragDropCopyCutPaste", "CopiedBeforeDragPastedAfterDrop" + projectType.CodeExtension); Assert.AreNotEqual(null, file); var draggedFile = solution.WaitForItem("DragDropCopyCutPaste", "DragAndDroppedDuringCopy" + projectType.CodeExtension); Assert.AreNotEqual(null, draggedFile); var dragFolder = solution.WaitForItem("DragDropCopyCutPaste", "DragDuringCopyDestination"); Assert.AreNotEqual(null, dragFolder); AutomationWrapper.Select(file); solution.ControlC(); MoveByMouse( solution, dragFolder, draggedFile ); var folder = solution.WaitForItem("DragDropCopyCutPaste", "PasteFolder"); AutomationWrapper.Select(folder); solution.ControlV(); solution.AssertFileExists("DragDropCopyCutPaste", "PasteFolder", "CopiedBeforeDragPastedAfterDrop" + projectType.CodeExtension); solution.AssertFileExists("DragDropCopyCutPaste", "CopiedBeforeDragPastedAfterDrop" + projectType.CodeExtension); } } }
public void RenameStartupFile() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition( "RenameStartupFileFolder", projectType, Folder("Folder"), Compile("Folder\\server"), Property("StartupFile", "Folder\\server" + projectType.CodeExtension) ); using (var solution = testDef.Generate().ToVs()) { var file = solution.GetProject("RenameStartupFileFolder").ProjectItems.Item("Folder").ProjectItems.Item("server" + projectType.CodeExtension); file.Name = "server2" + projectType.CodeExtension; Assert.AreEqual( "server2" + projectType.CodeExtension, Path.GetFileName( (string)solution.GetProject("RenameStartupFileFolder").Properties.Item("StartupFile").Value ) ); } } }
public void RenameStartupFileFolder() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition( "RenameStartupFileFolder", projectType, Folder("Folder"), Compile("Folder\\server"), Property("StartupFile", "Folder\\server" + projectType.CodeExtension) ); using (var solution = testDef.Generate().ToVs()) { var folder = solution.GetProject("RenameStartupFileFolder").ProjectItems.Item("Folder"); folder.Name = "FolderNew"; string startupFile = (string)solution.GetProject("RenameStartupFileFolder").Properties.Item("StartupFile").Value; Assert.IsTrue( startupFile.EndsWith(projectType.Code("FolderNew\\server")), "Expected FolderNew in path, got {0}", startupFile ); } } }
public void ShowAllFilesRapidChanges2() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesRapidChanges", projectType, Property("ProjectView", "ShowAllFiles") ); using (var solution = def.Generate().ToVs()) { var projectNode = solution.WaitForItem("ShowAllFilesRapidChanges"); AutomationWrapper.Select(projectNode); HashSet<string> addedItems = new HashSet<string>(); for (int i = 0; i < 100; i++) { var filename = Path.Combine(solution.SolutionDirectory, "ShowAllFilesRapidChanges", Path.GetRandomFileName()); File.WriteAllText(filename, ""); File.Delete(filename); File.WriteAllText(filename, ""); addedItems.Add(filename); } // give some time for changes to be processed... System.Threading.Thread.Sleep(10000); foreach (var item in addedItems) { Assert.IsNotNull(solution.WaitForItem("ShowAllFilesRapidChanges", Path.GetFileName(item)), item); } } } }
public void ShowAllFilesRapidChanges() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesRapidChanges", projectType, Property("ProjectView", "ShowAllFiles") ); using (var solution = def.Generate().ToVs()) { var projectNode = solution.WaitForItem("ShowAllFilesRapidChanges"); AutomationWrapper.Select(projectNode); List<string> addedItems = new List<string>(); for (int i = 0; i < 1000; i++) { var filename = Path.Combine(solution.SolutionDirectory, "ShowAllFilesRapidChanges", Path.GetRandomFileName()); File.WriteAllText(filename, ""); File.Delete(filename); addedItems.Add(filename); } foreach (var item in addedItems) { Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesRapidChanges", Path.GetFileName(item))); } } } }
public void ShowAllExcludeSelected() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllExcludeSelected", projectType, ItemGroup( Folder("Folder"), Compile("Folder\\File1"), Compile("Folder\\File2") ), Property("ProjectView", "ProjectFiles") ); using (var solution = def.Generate().ToVs()) { solution.WaitForItem("ShowAllExcludeSelected"); var file = solution.WaitForItem("ShowAllExcludeSelected", "Folder", "File2" + projectType.CodeExtension); AutomationWrapper.Select(file); solution.ExecuteCommand("Project.ExcludeFromProject"); solution.WaitForItemRemoved("ShowAllExcludeSelected", "Folder", "File2" + projectType.CodeExtension); Assert.AreEqual("File1" + projectType.CodeExtension, Path.GetFileName(GetSelectedItemName())); file = solution.WaitForItem("ShowAllExcludeSelected", "Folder", "File1" + projectType.CodeExtension); AutomationWrapper.Select(file); solution.ExecuteCommand("Project.ExcludeFromProject"); solution.WaitForItemRemoved("ShowAllExcludeSelected", "Folder", "File1" + projectType.CodeExtension); Assert.AreEqual("Folder", Path.GetFileName(GetSelectedItemName().TrimEnd('\\'))); } } }
public void ShowAllMoveNotInProject() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllMoveNotInProject", projectType, ItemGroup( Folder("Folder", isExcluded: true), Folder("Folder\\SubFolder", isExcluded: true), Compile("NotInProject", isExcluded:true), Compile("Folder\\File", isExcluded: true), Content("Folder\\SubFolder\\SubFile.txt", "", isExcluded: true) ), Property("ProjectView", "ShowAllFiles") ); using (var solution = def.Generate().ToVs()) { solution.WaitForItem("ShowAllMoveNotInProject"); var file = solution.WaitForItem("ShowAllMoveNotInProject", "NotInProject" + projectType.CodeExtension); AutomationWrapper.Select(file); Keyboard.ControlX(); System.Threading.Thread.Sleep(1000); var folder = solution.WaitForItem("ShowAllMoveNotInProject", "Folder"); AutomationWrapper.Select(folder); Keyboard.ControlV(); Assert.IsNotNull(solution.WaitForItem("ShowAllMoveNotInProject", "Folder", "NotInProject" + projectType.CodeExtension)); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNull(solution.WaitForItemRemoved("ShowAllMoveNotInProject", "Folder", "NotInProject" + projectType.CodeExtension)); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing again var subFolder = solution.WaitForItem("ShowAllMoveNotInProject", "Folder", "SubFolder"); AutomationWrapper.Select(subFolder); Keyboard.ControlX(); System.Threading.Thread.Sleep(1000); var projectNode = solution.WaitForItem("ShowAllMoveNotInProject"); AutomationWrapper.Select(projectNode); Keyboard.ControlV(); Assert.IsNotNull(solution.WaitForItem("ShowAllMoveNotInProject", "SubFolder")); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNull(solution.WaitForItemRemoved("ShowAllMoveNotInProject", "SubFolder")); } } }
public void ShowAllFilesDefault() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesDefault", projectType, Folder("SubFolder"), Compile("SubFolder\\server"), Compile("NotInProject", isExcluded: true), Property("ProjectView", "") ); using (var solution = def.Generate().ToVs()) { var projectNode = solution.WaitForItem("ShowAllFilesDefault"); AutomationWrapper.Select(projectNode); Assert.IsNull(solution.FindItem("ShowAllFilesDefault", "NotInProject" + projectType.CodeExtension)); // change setting, UI should be updated solution.ExecuteCommand("Project.ShowAllFiles"); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesDefault", "NotInProject" + projectType.CodeExtension)); // save setting, user project file should be updated solution.GetProject("ShowAllFilesDefault").Save(); var projectText = File.ReadAllText(Path.Combine(solution.SolutionDirectory, @"ShowAllFilesDefault\ShowAllFilesDefault" + projectType.ProjectExtension + ".user")); Assert.IsTrue(projectText.Contains("<ProjectView>ShowAllFiles</ProjectView>")); } } }
/// <summary> /// Copy folder to a destination where the folder already exists. Say don't copy, nothing should be copied. /// </summary> private void CopyDuplicateFolderName(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("CopyDuplicateFolderName"), Compile("CopyDuplicateFolderName\\server"), Folder("CopyDuplicateFolderNameTarget"), Folder("CopyDuplicateFolderNameTarget\\CopyDuplicateFolderName") ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "CopyDuplicateFolderNameTarget"), solution.WaitForItem("DragDropCopyCutPaste", "CopyDuplicateFolderName") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { AssertUtil.Contains(dialog.Text, "This folder already contains a folder called 'CopyDuplicateFolderName'"); dialog.No(); } solution.AssertFileDoesntExist("DragDropCopyCutPaste", "CopyDuplicateFolderNameTarget", "CopyDuplicateFolderName", "server" + projectType.CodeExtension); } } }
/// <summary> /// Move item within the project from one location to where it already exists, skipping the move. /// </summary> private void MoveDuplicateFileNameSkipMove(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("MoveDuplicateFileName", projectType, ItemGroup( Folder("Folder"), Content("textfile.txt", "root"), Content("Folder\\textfile.txt", "Folder") ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.FindItem("MoveDuplicateFileName", "Folder"), solution.FindItem("MoveDuplicateFileName", "textfile.txt") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.No(); } solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("root", "MoveDuplicateFileName", "textfile.txt"); solution.AssertFileExistsWithContent("Folder", "MoveDuplicateFileName", "Folder", "textfile.txt"); } } }
public void ShowAllFilesIncludeExclude() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesIncludeExclude", projectType, ItemGroup( Folder("ExcludeFolder1"), Folder("ExcludeFolder2"), Folder("IncludeFolder1", isExcluded: true), Folder("IncludeFolder2", isExcluded: true), Folder("IncludeFolder3", isExcluded: true), Folder("NotOnDiskFolder", isMissing: true) ), ItemGroup( Compile("NotInProject", isExcluded: true), Compile("server"), Compile("NotOnDisk", isMissing: true), Content("ExcludeFolder1\\Item.txt", ""), Content("ExcludeFolder2\\Item.txt", ""), Content("IncludeFolder1\\Item.txt", "", isExcluded: true), Content("IncludeFolder2\\Item.txt", "", isExcluded: true), Content("IncludeFolder2\\Item2.txt", "", isExcluded: true), Content("IncludeFolder3\\Text.txt", "", isExcluded: true), Compile("..\\LinkedFile") ), PropertyGroup( Property("ProjectView", "ShowAllFiles"), StartupFile("server") ) ); using (var solution = def.Generate().ToVs()) { var projectNode = solution.WaitForItem("ShowAllFilesIncludeExclude"); var excludedFolder = solution.GetProject("ShowAllFilesIncludeExclude").ProjectItems.Item("ExcludeFolder1"); var itemTxt = excludedFolder.ProjectItems.Item("Item.txt"); var buildAction = itemTxt.Properties.Item("BuildAction"); Assert.IsNotNull(buildAction); var notInProject = solution.WaitForItem("ShowAllFilesIncludeExclude", "NotInProject" + projectType.CodeExtension); AutomationWrapper.Select(notInProject); var folder = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1"); AutomationWrapper.Select(folder); solution.ExecuteCommand("Project.ExcludeFromProject"); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "ExcludeFolder1")); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all again Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1")); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1", "Item.txt")); // https://nodejstools.codeplex.com/workitem/250 var linkedFile = solution.WaitForItem("ShowAllFilesIncludeExclude", "LinkedFile" + projectType.CodeExtension); AutomationWrapper.Select(linkedFile); solution.ExecuteCommand("Project.ExcludeFromProject"); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "LinkedFile" + projectType.CodeExtension)); // https://pytools.codeplex.com/workitem/1153 // Shouldn't have a BuildAction property on excluded items try { solution.GetProject("ShowAllFilesIncludeExclude").ProjectItems.Item("ExcludedFolder1").ProjectItems.Item("Item.txt").Properties.Item("BuildAction"); Assert.Fail("Excluded item had BuildAction"); } catch (ArgumentException) { } var file = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder2", "Item.txt"); AutomationWrapper.Select(file); solution.ExecuteCommand("Project.ExcludeFromProject"); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "ExcludeFolder2", "Item.txt")); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all var itemTxtNode = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder2", "Item.txt"); Assert.IsNotNull(itemTxtNode); AutomationWrapper.Select(itemTxtNode); // https://pytools.codeplex.com/workitem/1143 try { solution.ExecuteCommand("Project.AddNewItem"); Assert.Fail("Added a new item on excluded node"); } catch (COMException) { } var excludedFolderNode = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1"); Assert.IsNotNull(excludedFolderNode); AutomationWrapper.Select(excludedFolderNode); try { solution.ExecuteCommand("Project.NewFolder"); Assert.Fail("Added a new folder on excluded node"); } catch (COMException) { } // include folder = solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1"); AutomationWrapper.Select(folder); solution.ExecuteCommand("Project.IncludeInProject"); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1")); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1", "Item.txt")); // https://nodejstools.codeplex.com/workitem/242 // Rename Item.txt on disk File.Move( Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\Item.txt"), Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\ItemNew.txt") ); var includedItem = solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1", "Item.txt"); AutomationWrapper.Select(includedItem); solution.ExecuteCommand("Project.ExcludeFromProject"); // Rename it back File.Move( Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\ItemNew.txt"), Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\Item.txt") ); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all // item should be back Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1", "Item.txt")); folder = solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder2", "Item.txt"); AutomationWrapper.Select(folder); solution.ExecuteCommand("Project.IncludeInProject"); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder2")); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder2", "Item.txt")); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "IncludeFolder2", "Item2.txt")); AutomationWrapper.Select(projectNode); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all // exclude an item which exists, but is not on disk, it should be removed var notOnDisk = solution.WaitForItem("ShowAllFilesIncludeExclude", "NotOnDisk" + projectType.CodeExtension); AutomationWrapper.Select(notOnDisk); solution.ExecuteCommand("Project.ExcludeFromProject"); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "NotOnDisk" + projectType.CodeExtension)); var notOnDiskFolder = solution.WaitForItem("ShowAllFilesIncludeExclude", "NotOnDiskFolder"); AutomationWrapper.Select(notOnDiskFolder); solution.ExecuteCommand("Project.ExcludeFromProject"); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "NotOnDiskFolder")); // https://pytools.codeplex.com/workitem/1138 var server = solution.FindItem("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension); AutomationWrapper.Select(server); Keyboard.ControlC(); System.Threading.Thread.Sleep(1000); var includeFolder3 = solution.FindItem("ShowAllFilesIncludeExclude", "IncludeFolder3"); AutomationWrapper.Select(includeFolder3); Keyboard.ControlV(); System.Threading.Thread.Sleep(1000); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all // folder should now be included Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder3")); // https://nodejstools.codeplex.com/workitem/250 // Excluding the startup item, and then including it again, it should be bold server = solution.FindItem("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension); AutomationWrapper.Select(server); solution.ExecuteCommand("Project.ExcludeFromProject"); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension)); solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all server = solution.FindItem("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension); AutomationWrapper.Select(server); solution.ExecuteCommand("Project.IncludeInProject"); System.Threading.Thread.Sleep(2000); Assert.IsTrue(solution.GetProject("ShowAllFilesIncludeExclude").GetIsItemBolded("server" + projectType.CodeExtension)); } } }
public void DragFolderOntoChild() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("ParentFolder"), Folder("ParentFolder\\ChildFolder") ) ); using (var solution = testDef.Generate().ToVs()) { MoveByMouse( solution, solution.WaitForItem("DragDropCopyCutPaste", "ParentFolder", "ChildFolder"), solution.WaitForItem("DragDropCopyCutPaste", "ParentFolder") ); solution.CheckMessageBox("Cannot move 'ParentFolder'. The destination folder is a subfolder of the source folder."); solution.WaitForDialogDismissed(); var draggedFolder = solution.FindItem("DragDropCopyCutPaste", "ParentFolder"); Assert.IsNotNull(draggedFolder); var childFolder = solution.FindItem("DragDropCopyCutPaste", "ParentFolder", "ChildFolder"); Assert.IsNotNull(childFolder); var parentInChildFolder = solution.FindItem("DragDropCopyCutPaste", "ParentFolder", "ChildFolder", "ParentFolder"); Assert.IsNull(parentInChildFolder); } } }
public void CutFilePasteSameLocation() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Compile("CutFilePasteSameLocation") ) ); using (var solution = testDef.Generate().ToVs()) { MoveByKeyboard( solution, solution.WaitForItem("DragDropCopyCutPaste"), solution.WaitForItem("DragDropCopyCutPaste", "CutFilePasteSameLocation" + projectType.CodeExtension) ); solution.CheckMessageBox("Cannot move 'CutFilePasteSameLocation" + projectType.CodeExtension + "'. The destination folder is the same as the source folder."); solution.AssertFileExists("DragDropCopyCutPaste", "CutFilePasteSameLocation" + projectType.CodeExtension); solution.AssertFileDoesntExist("DragDropCopyCutPaste", "CutFilePasteSameLocation - Copy" + projectType.CodeExtension); } } }
public void DragFolderAndFileOntoSelf() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("DragFolderAndFileOntoSelf"), Compile("DragFolderAndFileOntoSelf\\File") ) ); using (var solution = testDef.Generate().ToVs()) { var folder = solution.WaitForItem("DragDropCopyCutPaste", "DragFolderAndFileOntoSelf"); DragAndDrop( solution, folder, folder, solution.WaitForItem("DragDropCopyCutPaste", "DragFolderAndFileOntoSelf", "File" + projectType.CodeExtension) ); solution.CheckMessageBox("Cannot move 'DragFolderAndFileOntoSelf'. The destination folder is the same as the source folder."); } } }
public void CopyDeletePaste() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("CopyDeletePaste"), Compile("CopyDeletePaste\\CopyDeletePaste") ) ); using (var solution = testDef.Generate().ToVs()) { var file = solution.WaitForItem("DragDropCopyCutPaste", "CopyDeletePaste", "CopyDeletePaste" + projectType.CodeExtension); var project = solution.WaitForItem("DragDropCopyCutPaste"); AutomationWrapper.Select(file); solution.ControlC(); AutomationWrapper.Select(file); solution.Type(Key.Delete); solution.WaitForDialog(); solution.Type("\r"); solution.WaitForDialogDismissed(); solution.WaitForItemRemoved("DragDropCopyCutPaste", "CopyDeletePaste", "CopyDeletePaste" + projectType.CodeExtension); AutomationWrapper.Select(project); solution.ControlV(); solution.CheckMessageBox("The source URL 'CopyDeletePaste" + projectType.CodeExtension + "' could not be found."); } } }
/// <summary> /// Cuts 2 files with the same name, answers yes to overwrite them, and /// makes sure only one file is left. /// </summary> /// <param name="mover"></param> private void MoveDuplicateFileNameOverwrite(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var project = new ProjectDefinition( "DragDropCopyCutPaste", projectType, ItemGroup( Folder("A"), Folder("B"), Content("quox.txt", "top-level"), Content("A\\quox.txt", "A") ) ); using (var solution = project.Generate().ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "B"), solution.WaitForItem("DragDropCopyCutPaste", "A", "quox.txt"), solution.WaitForItem("DragDropCopyCutPaste", "quox.txt") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { AssertUtil.Contains(dialog.Text, "A file with the same name 'quox.txt' already exists."); dialog.Yes(); } solution.AssertFileExists("DragDropCopyCutPaste", "B", "quox.txt"); solution.AssertFileDoesntExist("DragDropCopyCutPaste", "quox.txt"); solution.AssertFileDoesntExist("DragDropCopyCutPaste", "A", "quox.txt"); Assert.AreEqual(1, solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("B").ProjectItems.Count); } } }
/// <summary> /// https://pytools.codeplex.com/workitem/1909 /// </summary> private void ShowAllFilesMoveExcludedItemToExcludedFolder(DragDropCopyCutPaste.MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesMoveExcludedItemToExcludedFolder", projectType, Property("ProjectView", "ShowAllFiles"), Folder("NewFolder1", isExcluded: true), Compile("server", isExcluded: true) ); using (var solution = def.Generate().ToVs()) { var projectNode = solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder"); AutomationWrapper.Select(projectNode); mover( solution, solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1"), solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder", "server" + projectType.CodeExtension) ); Assert.IsNotNull( solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1", "server" + projectType.CodeExtension) ); solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all Assert.IsNull( solution.WaitForItemRemoved("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1") ); Assert.IsNull( solution.WaitForItemRemoved("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1", "server" + projectType.CodeExtension) ); } } }
public void CutFolderAndFile() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("CutFolderAndFile"), Folder("CutFolderAndFile\\CutFolder"), Compile("CutFolderAndFile\\CutFolder\\CutFolderAndFile") ) ); using (var solution = testDef.Generate().ToVs()) { var folder = solution.WaitForItem("DragDropCopyCutPaste", "CutFolderAndFile", "CutFolder"); var file = solution.WaitForItem("DragDropCopyCutPaste", "CutFolderAndFile", "CutFolder", "CutFolderAndFile" + projectType.CodeExtension); var dest = solution.WaitForItem("DragDropCopyCutPaste"); AutomationWrapper.Select(folder); AutomationWrapper.AddToSelection(file); solution.ControlX(); AutomationWrapper.Select(dest); solution.ControlV(); solution.AssertFileExists("DragDropCopyCutPaste", "CutFolder", "CutFolderAndFile" + projectType.CodeExtension); solution.AssertFileDoesntExist("DragDropCopyCutPaste", "CutFolderAndFile", "CutFolder"); } } }
public void CutFileReplace() { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("MoveDupFilename"), Folder("MoveDupFilename\\Fob"), Compile("MoveDupFilename\\Fob\\server"), Compile("MoveDupFilename\\server") ) ); using (var solution = testDef.Generate().ToVs()) { MoveByKeyboard( solution, solution.WaitForItem("DragDropCopyCutPaste", "MoveDupFilename"), solution.WaitForItem("DragDropCopyCutPaste", "MoveDupFilename", "Fob", "server" + projectType.CodeExtension) ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.Yes(); } solution.AssertFileExists("DragDropCopyCutPaste", "MoveDupFilename", "server" + projectType.CodeExtension); solution.AssertFileDoesntExist("DragDropCopyCutPaste", "MoveDupFilename", "Fob", "server" + projectType.CodeExtension); } } }
public void ShowAllFilesHiddenFiles() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesHiddenFiles", projectType, ItemGroup( Folder("Folder", isExcluded: true), Folder("HiddenFolder", isExcluded: true) ), ItemGroup( Compile("NotInProject", isExcluded: true), Compile("NotInProject2", isExcluded: true), Compile("server"), Content("Folder\\File.txt", "", isExcluded: true), Content("Folder\\File2.txt", "", isExcluded: true), Content("HiddenFolder\\HiddenFile.txt", "", isExcluded: true) ), PropertyGroup( Property("ProjectView", "ShowAllFiles") ) ); var solutionFile = def.Generate(); var file = Path.Combine(solutionFile.Directory, @"ShowAllFilesHiddenFiles\NotInProject" + projectType.CodeExtension); File.SetAttributes( file, File.GetAttributes(file) | FileAttributes.Hidden ); file = Path.Combine(solutionFile.Directory, @"ShowAllFilesHiddenFiles\Folder\File.txt"); File.SetAttributes( file, File.GetAttributes(file) | FileAttributes.Hidden ); file = Path.Combine(solutionFile.Directory, @"ShowAllFilesHiddenFiles\HiddenFolder"); File.SetAttributes( file, File.GetAttributes(file) | FileAttributes.Hidden ); using (var solution = solutionFile.ToVs()) { var projectNode = solution.WaitForItem("ShowAllFilesHiddenFiles"); // hidden files/folders shouldn't be visible Assert.IsNull(solution.FindItem("ShowAllFilesHiddenFiles", "NotInProject" + projectType.CodeExtension)); Assert.IsNull(solution.FindItem("ShowAllFilesHiddenFiles", "Folder", "File.txt")); Assert.IsNull(solution.FindItem("ShowAllFilesHiddenFiles", "HiddenFolder")); // but if they change back, they should be file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\NotInProject" + projectType.CodeExtension); File.SetAttributes( file, File.GetAttributes(file) & ~FileAttributes.Hidden ); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "NotInProject" + projectType.CodeExtension)); file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\Folder\File.txt"); File.SetAttributes( file, File.GetAttributes(file) & ~FileAttributes.Hidden ); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "Folder", "File.txt")); file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\HiddenFolder"); File.SetAttributes( file, File.GetAttributes(file) & ~FileAttributes.Hidden ); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "HiddenFolder")); // changing non-hidden items to hidden should cause them to be removed Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "NotInProject2" + projectType.CodeExtension)); file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\NotInProject2" + projectType.CodeExtension); File.SetAttributes( file, File.GetAttributes(file) | FileAttributes.Hidden ); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesHiddenFiles", "NotInProject2" + projectType.CodeExtension)); Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "Folder")); file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\Folder"); File.SetAttributes( file, File.GetAttributes(file) | FileAttributes.Hidden ); Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesHiddenFiles", "Folder")); } } }
/// <summary> /// Cut 2 items, paste where they exist, skip pasting the 1st one but paste the 2nd. /// /// The 1st item shouldn't be removed from the parent hierarchy, the 2nd should, and only the 2nd item should be overwritten. /// </summary> private void MoveDuplicateFileNamesFoldersSkipOne(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("MoveDuplicateFileName", projectType, ItemGroup( Folder("Source"), Content("Source\\textfile1.txt", "source1"), Content("Source\\textfile2.txt", "source2"), Folder("Target"), Content("Target\\textfile1.txt", "target1"), Content("Target\\textfile2.txt", "target2") ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.FindItem("MoveDuplicateFileName", "Target"), solution.FindItem("MoveDuplicateFileName", "Source", "textfile1.txt"), solution.FindItem("MoveDuplicateFileName", "Source", "textfile2.txt") ); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.No(); } System.Threading.Thread.Sleep(1000); using (var dialog = solution.WaitForOverwriteFileDialog()) { dialog.Yes(); } solution.WaitForDialogDismissed(); solution.AssertFileExistsWithContent("source1", "MoveDuplicateFileName", "Source", "textfile1.txt"); solution.AssertFileDoesntExist("MoveDuplicateFileName", "textfile2.txt"); solution.AssertFileExistsWithContent("target1", "MoveDuplicateFileName", "Target", "textfile1.txt"); solution.AssertFileExistsWithContent("source2", "MoveDuplicateFileName", "Target", "textfile2.txt"); } } }
/// <summary> /// Drag file from another hierarchy into folder in our hierarchy, item should be added /// Cannot move the folder 'DuplicateFolderName'. A folder with that name already exists in the destination directory. /// </summary> private void MoveDuplicateFolderName(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("DragDropCopyCutPaste", projectType, ItemGroup( Folder("DuplicateFolderName"), Folder("DuplicateFolderNameTarget"), Folder("DuplicateFolderNameTarget\\DuplicateFolderName") ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.WaitForItem("DragDropCopyCutPaste", "DuplicateFolderNameTarget"), solution.WaitForItem("DragDropCopyCutPaste", "DuplicateFolderName") ); solution.CheckMessageBox("Cannot move the folder 'DuplicateFolderName'. A folder with that name already exists in the destination directory."); } } }
private void MoveExcludedFolder(MoveDelegate mover) { foreach (var projectType in ProjectTypes) { var testDef = new ProjectDefinition("MoveExcludedFolder", projectType, PropertyGroup( Property("ProjectView", "ShowAllFiles") ), ItemGroup( Folder("Fob", isExcluded: true), Folder("Fob\\Oar", isExcluded: true), Folder("Baz", isExcluded: true) ) ); using (var solution = testDef.Generate().ToVs()) { mover( solution, solution.FindItem("MoveExcludedFolder", "Baz"), solution.FindItem("MoveExcludedFolder", "Fob") ); solution.AssertFolderDoesntExist("MoveExcludedFolder", "Fob"); solution.AssertFolderExists("MoveExcludedFolder", "Baz", "Fob"); } } }
public void ShowAllFilesLinked() { foreach (var projectType in ProjectTypes) { var def = new ProjectDefinition( "ShowAllFilesLinked", projectType, Compile("..\\File"), Folder("SubFolder"), Compile("..\\LinkedFile").Link("SubFolder\\LinkedFile"), Property("ProjectView", "ProjectFiles") ); using (var solution = def.Generate().ToVs()) { var linkedNode = solution.WaitForItem("ShowAllFilesLinked", "File" + projectType.CodeExtension); AutomationWrapper.Select(linkedNode); Keyboard.ControlC(); var subFolder = solution.WaitForItem("ShowAllFilesLinked", "SubFolder"); AutomationWrapper.Select(subFolder); Keyboard.ControlV(); VisualStudioApp.CheckMessageBox("Cannot copy linked files within the same project. You cannot have more than one link to the same file in a project."); linkedNode = solution.WaitForItem("ShowAllFilesLinked", "SubFolder", "LinkedFile" + projectType.CodeExtension); AutomationWrapper.Select(linkedNode); Keyboard.ControlX(); var projectNode = solution.WaitForItem("ShowAllFilesLinked"); AutomationWrapper.Select(projectNode); Keyboard.ControlV(); solution.GetProject("ShowAllFilesLinked").Save(); var text = File.ReadAllText(Path.Combine(solution.SolutionDirectory, @"ShowAllFilesLinked\ShowAllFilesLinked" + projectType.ProjectExtension)); Assert.IsTrue(text.IndexOf("<Link>LinkedFile" + projectType.CodeExtension + "</Link>") != -1); } } }