Esempio n. 1
0
        public void BraceCompletionsBasic()
        {
            using (var solution = BasicProject.Generate().ToVs()) {
                var server = solution.OpenItem("Require", "SomeFolder", "baz.js");

                // Test '('
                Keyboard.Type("(");
                server.WaitForText("()");
            }
        }
Esempio n. 2
0
        public void BraceCompletionsBasic()
        {
            using (var solution = BasicProject.Generate().ToVs()) {
                string folderName = NodejsFolderNode.AppendLabel("SomeFolder", FolderContentType.Node);
                var    server     = solution.OpenItem("Require", folderName, "baz.js");

                // Test '('
                Keyboard.Type("(");
                server.WaitForText("()");
            }
        }
Esempio n. 3
0
 public void SmartIndentBug1198()
 {
     using (var solution = BasicProject.Generate().ToVs()) {
         var doc = solution.OpenItem("AutoIndent", "Bug1198.js");
         doc.Invoke(() => doc.TextView.Caret.MoveTo(doc.TextView.TextViewLines[4]));
         Keyboard.Type(System.Windows.Input.Key.End);
         Keyboard.Type(" ");
         Assert.AreEqual(
             9,
             doc.TextView.Caret.Position.BufferPosition.GetContainingLine().Length
             );
     }
 }
Esempio n. 4
0
        private void MoveExcludedItemToFolder(VisualStudioApp app, ProjectGenerator pg, MoveDelegate mover)
        {
            foreach (var projectType in pg.ProjectTypes)
            {
                var testDef = new ProjectDefinition("MoveExcludedItemToFolder",
                                                    projectType,
                                                    ProjectGenerator.PropertyGroup(
                                                        ProjectGenerator.Property("ProjectView", "ShowAllFiles")
                                                        ),
                                                    ProjectGenerator.ItemGroup(
                                                        ProjectGenerator.Folder("Folder"),
                                                        ProjectGenerator.Compile("codefile", isExcluded: true)
                                                        )
                                                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    mover(
                        solution,
                        solution.FindItem("MoveExcludedItemToFolder", "Folder"),
                        solution.FindItem("MoveExcludedItemToFolder", "codefile" + projectType.CodeExtension)
                        );

                    solution.AssertFileDoesntExist("MoveExcludedItemToFolder", "codefile" + projectType.CodeExtension);
                    solution.AssertFileExists("MoveExcludedItemToFolder", "Folder", "codefile" + projectType.CodeExtension);
                    Assert.IsTrue(solution.GetProject("MoveExcludedItemToFolder").GetIsFolderExpanded("Folder"));
                }
            }
        }
        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);
                }
            }
        }
Esempio n. 6
0
        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.");
                }
            }
        }
Esempio n. 7
0
        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
                        );
                }
            }
        }
Esempio n. 8
0
        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
                            )
                        );
                }
            }
        }
        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");
                }
            }
        }
        /// <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");
                }
            }
        }
Esempio n. 11
0
        public void InsertSnippet()
        {
            using (var solution = BasicProject.Generate().ToVs()) {
                using (new SnippetTestOptionHolder()) {
                    foreach (var snippet in BasicSnippets)
                    {
                        TestOneInsertSnippet(solution, snippet, "Nodejs");

                        solution.CloseActiveWindow(vsSaveChanges.vsSaveChangesNo);
                    }
                }
            }
        }
Esempio n. 12
0
        // 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)
                                             );
                    }
                }
            }
        }
Esempio n. 13
0
        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 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");
                }
            }
        }
Esempio n. 15
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 MoveDuplicateFileNamesSkipOne(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("textfile1.txt", "root1"),
                                                        ProjectGenerator.Content("textfile2.txt", "root2"),
                                                        ProjectGenerator.Content("Folder\\textfile1.txt", "Folder1"),
                                                        ProjectGenerator.Content("Folder\\textfile2.txt", "Folder2")
                                                        )
                                                    );

                using (var solution = testDef.Generate().ToVs(app)) {
                    mover(
                        solution,
                        solution.FindItem("MoveDuplicateFileName", "Folder"),
                        solution.FindItem("MoveDuplicateFileName", "textfile1.txt"),
                        solution.FindItem("MoveDuplicateFileName", "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("root1", "MoveDuplicateFileName", "textfile1.txt");
                    solution.AssertFileDoesntExist("MoveDuplicateFileName", "textfile2.txt");
                    solution.AssertFileExistsWithContent("Folder1", "MoveDuplicateFileName", "Folder", "textfile1.txt");
                    solution.AssertFileExistsWithContent("root2", "MoveDuplicateFileName", "Folder", "textfile2.txt");
                }
            }
        }
        public void InSubFolder()
        {
            using (var solution = BasicProject.Generate().ToVs()) {
                var server = solution.OpenItem("Require", "SomeFolder", "baz.js");
                Keyboard.Type("require(");

                using (var completionSession = server.WaitForSession <ICompletionSession>()) {
                    Assert.AreEqual(1, completionSession.Session.CompletionSets.Count);

                    // we pick up built-ins, folders w/ package.json, and peers
                    AssertUtil.ContainsAtLeast(
                        completionSession.Session.GetDisplayTexts(),
                        "http",
                        "Foo",
                        "quox.js"
                        );

                    AssertUtil.DoesntContain(completionSession.Session.GetDisplayTexts(), "./SomeFolder/baz.js");
                    AssertUtil.DoesntContain(completionSession.Session.GetDisplayTexts(), "./myapp.js");

                    AssertUtil.ContainsAtLeast(
                        completionSession.Session.GetInsertionTexts(),
                        "'http'",
                        "'Foo'",
                        "'quox.js'"
                        );

                    Keyboard.Type("quo\t)");

                    server.WaitForText("require('quox.js')");
                }
            }
        }
Esempio n. 17
0
        public void BasicRequireCompletions()
        {
            using (var solution = BasicProject.Generate().ToVs()) {
                var server = solution.OpenItem("Require", "server.js");
                Keyboard.Type("require(");

                using (var completionSession = server.WaitForSession <ICompletionSession>()) {
                    Assert.AreEqual(1, completionSession.Session.CompletionSets.Count);

                    // we pick up built-ins, folders w/ package.json, and peers
                    AssertUtil.ContainsAtLeast(
                        completionSession.Session.GetDisplayTexts(),
                        "http",
                        "./myapp.js",
                        "./SomeFolder/baz.js",
                        "quox.js"
                        );

                    // we don't show our own file
                    AssertUtil.DoesntContain(completionSession.Session.GetDisplayTexts(), "./server.js");

                    AssertUtil.ContainsAtLeast(
                        completionSession.Session.GetInsertionTexts(),
                        "'http'",
                        "'./myapp.js'",
                        "'./SomeFolder/baz.js'",
                        "'quox.js'"
                        );

                    Keyboard.Type("htt");
                    server.WaitForText("require(htt)");

                    // we should be filtered down
                    AssertUtil.ContainsExactly(
                        completionSession.Session.GetDisplayTexts(),
                        "http",
                        "https"
                        );

                    // this should trigger completion
                    Keyboard.Type(")");
                    server.WaitForText("require('http')");
                }

                Keyboard.Backspace(8);
                server.WaitForText("require");

                Keyboard.Type("(");
                using (var completionSession = server.WaitForSession <ICompletionSession>()) {
                    Assert.AreEqual(1, completionSession.Session.CompletionSets.Count);

                    // this should dismiss the session and not complete anything
                    Keyboard.Type("'".ToString());
                    server.WaitForText("require('')");

                    Assert.IsTrue(completionSession.Session.IsDismissed);
                }

                Keyboard.Backspace(2);
                server.WaitForText("require");

                Keyboard.Type("(");
                using (var completionSession = server.WaitForSession <ICompletionSession>()) {
                    Assert.AreEqual(1, completionSession.Session.CompletionSets.Count);

                    // this should dismiss the session and not complete anything
                    Keyboard.Type("\"".ToString());
                    server.WaitForText("require(\"\")");

                    Assert.IsTrue(completionSession.Session.IsDismissed);
                }
            }
        }