예제 #1
0
        private void MoveExcludedFolder(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition("MoveExcludedFolder",
                                                    projectType,
                                                    ProjectGenerator.PropertyGroup(
                                                        ProjectGenerator.Property("ProjectView", "ShowAllFiles")
                                                        ),
                                                    ProjectGenerator.ItemGroup(
                                                        ProjectGenerator.Folder("Fob", isExcluded: true),
                                                        ProjectGenerator.Folder("Fob\\Oar", isExcluded: true),
                                                        ProjectGenerator.Folder("Baz", isExcluded: true)
                                                        )
                                                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    mover(
                        solution,
                        solution.FindItem("MoveExcludedFolder", "Baz"),
                        solution.FindItem("MoveExcludedFolder", "Fob")
                        );

                    solution.AssertFolderDoesntExist("MoveExcludedFolder", "Fob");
                    solution.AssertFolderExists("MoveExcludedFolder", "Baz", "Fob");
                }
            }
        }
예제 #2
0
        public void CutRenamePaste()
        {
            var testDef = Generator.Project("DragDropCopyCutPaste",
                                            ProjectGenerator.ItemGroup(
                                                ProjectGenerator.Folder("CutRenamePaste"),
                                                ProjectGenerator.Compile("CutRenamePaste\\CutRenamePaste")
                                                )
                                            );

            using (var solution = testDef.Generate().ToMockVs()) {
                var project = solution.WaitForItem("DragDropCopyCutPaste");
                var file    = solution.WaitForItem("DragDropCopyCutPaste", "CutRenamePaste", $"CutRenamePaste{testDef.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{testDef.ProjectType.CodeExtension}' could not be found.");
            }
        }
예제 #3
0
        /// <summary>
        /// Move item within the project from one location to where it already exists, skipping the move.
        /// </summary>
        private void MoveDuplicateFileNameSkipMove(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition("MoveDuplicateFileName",
                                                    projectType,
                                                    ProjectGenerator.ItemGroup(
                                                        ProjectGenerator.Folder("Folder"),
                                                        ProjectGenerator.Content("textfile.txt", "root"),
                                                        ProjectGenerator.Content("Folder\\textfile.txt", "Folder")
                                                        )
                                                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    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");
                }
            }
        }
예제 #4
0
        private void MoveToMissingFolder(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition("MoveToMissingFolder",
                                                    projectType,
                                                    ProjectGenerator.PropertyGroup(
                                                        ProjectGenerator.Property("ProjectView", "ShowAllFiles")
                                                        ),
                                                    ProjectGenerator.ItemGroup(
                                                        ProjectGenerator.Folder("Fob", isExcluded: false, isMissing: true),
                                                        ProjectGenerator.Compile("codefile", isExcluded: false)
                                                        )
                                                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    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);
                }
            }
        }
예제 #5
0
        public void RenameStartupFile(VisualStudioApp app, ProjectGenerator pg)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition(
                    "RenameStartupFileFolder",
                    projectType,
                    ProjectGenerator.Folder("Folder"),
                    ProjectGenerator.Compile("Folder\\server"),
                    ProjectGenerator.Property("StartupFile", "Folder\\server" + projectType.CodeExtension)
                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    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
                            )
                        );
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Renaming the folder containing the startup script should update the startup script
        /// https://nodejstools.codeplex.com/workitem/476
        /// </summary>
        public void RenameStartupFileFolder(VisualStudioApp app, ProjectGenerator pg)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition(
                    "RenameStartupFileFolder",
                    projectType,
                    ProjectGenerator.Folder("Folder"),
                    ProjectGenerator.Compile("Folder\\server"),
                    ProjectGenerator.Property("StartupFile", "Folder\\server" + projectType.CodeExtension)
                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    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
                        );
                }
            }
        }
예제 #7
0
        /// <summary>
        /// https://nodejstools.codeplex.com/workitem/194
        ///
        /// Verifies that we deliver the right set of track events to the source
        /// when we move a folder with a file in it.
        ///
        /// The right set of events are based upon matching the same events the C#
        /// project system delivers.  Those can be using the TestSccPackage with a
        /// C# project.  Once enables in Tools->Options->Source Control you can get
        /// the list of events from Tools->Show Scc Track Document Events.
        /// </summary>
        // Currently Fails: https://pytools.codeplex.com/workitem/2609
        public void MoveFolderWithItem(VisualStudioApp app, ProjectGenerator pg)
        {
            // close any projects before switching source control...
            app.Dte.Solution.Close();

            app.SelectSourceControlProvider("Test Source Provider");

            ExpectSourceControl();

            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition("SourceControl", projectType,
                                                    ProjectGenerator.PropertyGroup(
                                                        ProjectGenerator.Property("SccProjectName", "HelloWorld"),
                                                        ProjectGenerator.Property("SccLocalPath", "LocalPath"),
                                                        ProjectGenerator.Property("SccAuxPath", "AuxPath"),
                                                        ProjectGenerator.Property("SccProvider", "TestProvider")
                                                        ),
                                                    ProjectGenerator.ItemGroup(
                                                        ProjectGenerator.Folder("Fob"),
                                                        ProjectGenerator.Folder("Fob\\Oar"),
                                                        ProjectGenerator.Compile("Program"),
                                                        ProjectGenerator.Compile("Fob\\Oar\\Quox")
                                                        )
                                                    );

                using (var solution = testDef.Generate()) {
                    TestSccProvider.DocumentEvents.Clear();

                    var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);
                    var window  = app.SolutionExplorerTreeView;
                    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);
                    app.MaybeCheckMessageBox(MessageBoxButton.Ok, "One or more files will be");

                    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)
                                         );
                }
            }
        }
예제 #8
0
        /// <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 MoveDuplicateFileNamesCrossProjectSkipOne(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var projectDefs = new[] {
                    new ProjectDefinition("MoveDuplicateFileName",
                                          projectType,
                                          ProjectGenerator.ItemGroup(
                                              ProjectGenerator.Content("textfile1.txt", "textfile1 - lang"),
                                              ProjectGenerator.Content("textfile2.txt", "textfile2 - lang")
                                              )
                                          ),
                    new ProjectDefinition("MoveDuplicateFileName2",
                                          projectType,
                                          ProjectGenerator.ItemGroup(
                                              ProjectGenerator.Folder("Folder"),
                                              ProjectGenerator.Content("textfile1.txt", "textfile1 - 2"),
                                              ProjectGenerator.Content("textfile2.txt", "textfile2 - 2")
                                              )
                                          )
                };

                using (var solution = SolutionFile.Generate("MoveDuplicateFileName", projectDefs).ToVs(app)) {
                    var item1 = solution.FindItem("MoveDuplicateFileName", "textfile1.txt");
                    var item2 = solution.FindItem("MoveDuplicateFileName", "textfile2.txt");
                    mover(
                        solution,
                        solution.FindItem("MoveDuplicateFileName2"),
                        item1,
                        item2
                        );

                    using (var dialog = solution.WaitForOverwriteFileDialog()) {
                        dialog.No();
                    }

                    System.Threading.Thread.Sleep(1000);

                    using (var dialog = solution.WaitForOverwriteFileDialog()) {
                        dialog.Yes();
                    }

                    solution.WaitForDialogDismissed();

                    solution.AssertFileExistsWithContent("textfile1 - lang", "MoveDuplicateFileName", "textfile1.txt");
                    solution.AssertFileExistsWithContent("textfile2 - lang", "MoveDuplicateFileName", "textfile2.txt");
                    solution.AssertFileExistsWithContent("textfile1 - 2", "MoveDuplicateFileName2", "textfile1.txt");
                    solution.AssertFileExistsWithContent("textfile2 - lang", "MoveDuplicateFileName2", "textfile2.txt");
                }
            }
        }
예제 #9
0
        private static ProjectDefinition LinkedFiles(ProjectType projectType)
        {
            return(new ProjectDefinition(
                       "LinkedFiles",
                       projectType,
                       ProjectGenerator.ItemGroup(
                           ProjectGenerator.Folder("MoveToFolder"),
                           ProjectGenerator.Folder("FolderWithAFile"),
                           ProjectGenerator.Folder("Fob"),
                           ProjectGenerator.Folder("..\\LinkedFilesDir", isExcluded: true),
                           ProjectGenerator.Folder("AlreadyLinkedFolder"),

                           ProjectGenerator.Compile("Program"),
                           ProjectGenerator.Compile("..\\ImplicitLinkedFile"),
                           ProjectGenerator.Compile("..\\ExplicitLinkedFile")
                           .Link("ExplicitDir\\ExplicitLinkedFile"),
                           ProjectGenerator.Compile("..\\ExplicitLinkedFileWrongFilename")
                           .Link("ExplicitDir\\Blah"),
                           ProjectGenerator.Compile("..\\MovedLinkedFile"),
                           ProjectGenerator.Compile("..\\MovedLinkedFileOpen"),
                           ProjectGenerator.Compile("..\\MovedLinkedFileOpenEdit"),
                           ProjectGenerator.Compile("..\\FileNotInProject"),
                           ProjectGenerator.Compile("..\\DeletedLinkedFile"),
                           ProjectGenerator.Compile("LinkedInModule")
                           .Link("Fob\\LinkedInModule"),
                           ProjectGenerator.Compile("SaveAsCreateLink"),
                           ProjectGenerator.Compile("..\\SaveAsCreateFile"),
                           ProjectGenerator.Compile("..\\SaveAsCreateFileNewDirectory"),
                           ProjectGenerator.Compile("FolderWithAFile\\ExistsOnDiskAndInProject"),
                           ProjectGenerator.Compile("FolderWithAFile\\ExistsInProjectButNotOnDisk", isMissing: true),
                           ProjectGenerator.Compile("FolderWithAFile\\ExistsOnDiskButNotInProject"),
                           ProjectGenerator.Compile("..\\LinkedFilesDir\\SomeLinkedFile")
                           .Link("Oar\\SomeLinkedFile"),
                           ProjectGenerator.Compile("..\\RenamedLinkFile")
                           .Link("Fob\\NewNameForLinkFile"),
                           ProjectGenerator.Compile("..\\BadLinkPath")
                           .Link("..\\BadLinkPathFolder\\BadLinkPath"),
                           ProjectGenerator.Compile("..\\RootedLinkIgnored")
                           .Link("C:\\RootedLinkIgnored"),
                           ProjectGenerator.Compile("C:\\RootedIncludeIgnored", isMissing: true)
                           .Link("RootedIncludeIgnored"),
                           ProjectGenerator.Compile("Fob\\AddExistingInProjectDirButNotInProject"),
                           ProjectGenerator.Compile("..\\ExistingItem", isExcluded: true),
                           ProjectGenerator.Compile("..\\ExistsInProjectButNotOnDisk", isExcluded: true),
                           ProjectGenerator.Compile("..\\ExistsOnDiskAndInProject", isExcluded: true),
                           ProjectGenerator.Compile("..\\ExistsOnDiskButNotInProject", isExcluded: true)
                           )
                       ));
        }
예제 #10
0
 private static ProjectDefinition SourceControlProject(ProjectType projectType)
 {
     return(new ProjectDefinition("SourceControl", projectType,
                                  ProjectGenerator.PropertyGroup(
                                      ProjectGenerator.Property("SccProjectName", "HelloWorld"),
                                      ProjectGenerator.Property("SccLocalPath", "LocalPath"),
                                      ProjectGenerator.Property("SccAuxPath", "AuxPath"),
                                      ProjectGenerator.Property("SccProvider", "TestProvider")
                                      ),
                                  ProjectGenerator.ItemGroup(
                                      ProjectGenerator.Folder("TestFolder"),
                                      ProjectGenerator.Compile("Program"),
                                      ProjectGenerator.Compile("TestFolder\\SubItem"),
                                      ProjectGenerator.Compile("ExcludedFile", isExcluded: true)
                                      )
                                  ));
 }
예제 #11
0
        /// <summary>
        /// Move item to a folder that has a symbolic link.  Verify we cannot move
        /// ourselves to ourselves and that moves are reflected in both the folder and its symbolic link.
        /// NOTE: Because of symbolic link creation, this test must be run as administrator.
        /// </summary>
        private void MoveFileFromFolderToLinkedFolder(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var projectDefs = new[] {
                    new ProjectDefinition("MoveLinkedFolder",
                                          projectType,
                                          ProjectGenerator.ItemGroup(
                                              ProjectGenerator.Content("textfile.txt", "text file contents"),
                                              ProjectGenerator.Folder("Folder"),
                                              ProjectGenerator.Content("Folder\\FileInFolder.txt", "File inside of linked folder..."),
                                              ProjectGenerator.SymbolicLink("FolderLink", "Folder")
                                              )
                                          )
                };

                using (var solution = SolutionFile.Generate("MoveLinkedFolder", projectDefs).ToVs(app)) {
                    mover(
                        solution,
                        solution.FindItem("MoveLinkedFolder", "FolderLink"),
                        solution.FindItem("MoveLinkedFolder", "Folder", "FileInFolder.txt")
                        );

                    // Say okay to the error that pops up since we can't move to ourselves.
                    solution.WaitForDialog();
                    Keyboard.Type(Key.Enter);

                    solution.WaitForDialogDismissed();

                    // Verify that after the dialog our files are still present.
                    solution.AssertFileExists("MoveLinkedFolder", "FolderLink", "FileInFolder.txt");
                    solution.AssertFileExists("MoveLinkedFolder", "Folder", "FileInFolder.txt");

                    // Now move the text file in the root.  Expect it to move and be in both.
                    mover(
                        solution,
                        solution.FindItem("MoveLinkedFolder", "FolderLink"),
                        solution.FindItem("MoveLinkedFolder", "textfile.txt")
                        );

                    solution.AssertFileExists("MoveLinkedFolder", "FolderLink", "textfile.txt");
                    solution.AssertFileExists("MoveLinkedFolder", "Folder", "textfile.txt");
                }
            }
        }
예제 #12
0
        /// <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(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition("MoveDuplicateFileName",
                                                    projectType,
                                                    ProjectGenerator.ItemGroup(
                                                        ProjectGenerator.Folder("Source"),
                                                        ProjectGenerator.Content("Source\\textfile1.txt", "source1"),
                                                        ProjectGenerator.Content("Source\\textfile2.txt", "source2"),

                                                        ProjectGenerator.Folder("Target"),
                                                        ProjectGenerator.Content("Target\\textfile1.txt", "target1"),
                                                        ProjectGenerator.Content("Target\\textfile2.txt", "target2")
                                                        )
                                                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    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");
                }
            }
        }
예제 #13
0
        /// <summary>
        /// Move item to where item exists across project types.
        /// </summary>
        private void MoveDuplicateFileNameCrossProjectCSharpSkipMove(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var projectDefs = new[] {
                    new ProjectDefinition("MoveDuplicateFileName1",
                                          projectType,
                                          ProjectGenerator.ItemGroup(
                                              ProjectGenerator.Content("textfile.txt", "MoveDuplicateFileName1")
                                              )
                                          ),
                    new ProjectDefinition("MoveDuplicateFileNameCS",
                                          ProjectType.CSharp,
                                          ProjectGenerator.ItemGroup(
                                              ProjectGenerator.Folder("Folder"),
                                              ProjectGenerator.Content("textfile.txt", "MoveDuplicateFileNameCS")
                                              )
                                          )
                };

                using (var solution = SolutionFile.Generate("MoveDuplicateFileName", projectDefs).ToVs(app)) {
                    mover(
                        solution,
                        solution.FindItem("MoveDuplicateFileNameCS"),
                        solution.FindItem("MoveDuplicateFileName1", "textfile.txt")
                        );

                    // say no to replacing in the C# project system
                    using (var dlg = AutomationDialog.WaitForDialog(app)) {
                        dlg.ClickButtonAndClose("No");
                    }

                    solution.AssertFileExistsWithContent("MoveDuplicateFileName1", "MoveDuplicateFileName1", "textfile.txt");
                    solution.AssertFileExistsWithContent("MoveDuplicateFileNameCS", "MoveDuplicateFileNameCS", "textfile.txt");
                }
            }
        }