Exemple #1
0
        public void TestPublishFtp()
        {
            using (var app = new VisualStudioApp()) {
                var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                string subDir  = Guid.NewGuid().ToString();
                string url     = TestFtpUrl + "/" + subDir;
                project.Properties.Item("PublishUrl").Value = url;
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                string dir = Path.Combine(FtpValidateDir, subDir);
                Debug.WriteLine(dir);

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Build.PublishSelection");
                System.Threading.Thread.Sleep(2000);
                var files = WaitForFiles(dir);
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                // do it again w/ the directories already existing
                File.Delete(files[0]);

                app.OpenSolutionExplorer().SelectProject(project);
                app.ExecuteCommand("Build.PublishSelection");
                files = WaitForFiles(dir);
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                Directory.Delete(dir, true);
            }
        }
Exemple #2
0
        public void TestPublishFilesImpersonate(VisualStudioApp app)
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            try {
                var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                string subDir  = Guid.NewGuid().ToString();
                project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                app.OpenSolutionExplorer().SelectProject(project);

                using (var creds = CredentialsDialog.PublishSelection(app)) {
                    creds.UserName = PrivateShareUserWithoutMachine;
                    creds.Password = PrivateSharePassword;
                    creds.OK();
                }

                string dir = Path.Combine(TestSharePrivate, subDir);

                var files = WaitForFiles(dir);

                Assert.IsNotNull(files, "Timed out waiting for files to publish");
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                Directory.Delete(dir, true);
            } finally {
                WNetCancelConnection2(TestSharePrivate, 0, true);
            }
        }
        internal static void CreateProject(VisualStudioApp app, string languageName, string templateName, string location, string projectName, string expectedProjectItem)
        {
            using (var newProjDialog = app.FileNewProject())
            {
                newProjDialog.FocusLanguageNode(languageName);
                newProjDialog.Location    = location;
                newProjDialog.ProjectName = projectName;

                var djangoApp = newProjDialog.ProjectTypes.FindItem(templateName);
                djangoApp.Select();
                newProjDialog.OK();
            }

            // wait for new solution to load...
            for (int i = 0; i < 40 && app.Dte.Solution.Projects.Count == 0; i++)
            {
                System.Threading.Thread.Sleep(250);
            }

            app.OpenSolutionExplorer().WaitForItem(
                "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                app.Dte.Solution.Projects.Item(1).Name,
                expectedProjectItem
                );
        }
Exemple #4
0
        public void CutPasteRelocatedTest(VisualStudioApp app)
        {
            var sln    = app.CopyProjectForTest(@"TestData\CutPasteRelocatedTest.sln");
            var slnDir = PathUtils.GetParent(sln);

            FileUtils.CopyDirectory(TestData.GetPath("TestData", "CutPasteRelocatedTest"), Path.Combine(slnDir, "CutPasteRelocatedTest"));
            app.OpenProject(sln);

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            var folder = window.FindItem("Solution 'CutPasteRelocatedTest' (1 project)", "CutPasteTest", "TestFolder", "SubItem.py");

            AutomationWrapper.Select(folder);
            app.ExecuteCommand("Edit.Cut");

            var projectItem = window.FindItem("Solution 'CutPasteRelocatedTest' (1 project)", "CutPasteTest");

            AutomationWrapper.Select(projectItem);
            app.ExecuteCommand("Edit.Paste");

            Assert.IsNotNull(window.WaitForItem("Solution 'CutPasteRelocatedTest' (1 project)", "CutPasteTest", "SubItem.py"));

            app.Dte.Solution.Close(true);
            // Ensure file was moved and the path was updated correctly.
            var project = app.OpenProject(sln);

            foreach (var item in project.ProjectItems.OfType <OAFileItem>())
            {
                Assert.IsTrue(File.Exists((string)item.Properties.Item("FullPath").Value), (string)item.Properties.Item("FullPath").Value);
            }
        }
Exemple #5
0
        public void CopyPasteFile()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                // find server.js, send copy & paste, verify copy of file is there
                var programPy = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server.js");

                AutomationWrapper.Select(programPy);

                Keyboard.ControlC();
                Keyboard.ControlV();

                Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy.js"));

                AutomationWrapper.Select(programPy);
                Keyboard.ControlC();
                Keyboard.ControlV();

                Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy (2).js"));
            }
        }
Exemple #6
0
        public void MultiSelectCopyAndPaste()
        {
            using (var app = new VisualStudioApp())
            {
                app.OpenProject(@"TestData\NodejsProjectData\MultiSelectCopyAndPaste.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server.js");
                    Mouse.MoveTo(folderNode.GetClickablePoint());
                    Mouse.Click();

                    Keyboard.Press(Key.LeftShift);
                    Keyboard.PressAndRelease(Key.Down);
                    Keyboard.PressAndRelease(Key.Down);
                    Keyboard.Release(Key.LeftShift);
                    Keyboard.ControlC();

                    var projectNode = window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste");

                    AutomationWrapper.Select(projectNode);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server - Copy.js"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server2 - Copy.js"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server3 - Copy.js"));
                }
            }
        }
Exemple #7
0
        public void MoveStartupFile()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\MoveStartupFile.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var server = window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "server.js");
                    var folder = window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "TestDir");

                    AutomationWrapper.Select(server);
                    Keyboard.ControlX();

                    AutomationWrapper.Select(folder);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "TestDir", "server.js"));

                    Assert.IsTrue(((string)project.Properties.Item("StartupFile").Value).EndsWith("TestDir\\server.js"));
                }
            }
        }
Exemple #8
0
        public void CrossProjectCutPaste()
        {
            using (var app = new VisualStudioApp())
            {
                app.OpenProject(@"TestData\NodejsProjectData\HelloWorld2.sln", expectedProjects: 2);

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder2");
                    AutomationWrapper.Select(folderNode);

                    Keyboard.ControlX();

                    var projectNode = window.FindItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld");

                    AutomationWrapper.Select(projectNode);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld", "TestFolder2"));
                    Assert.AreEqual(null, window.WaitForItemRemoved("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder2"));
                }
            }
        }
Exemple #9
0
        public void DragLeaveFolderTest()
        {
            using (var app = new VisualStudioApp())
            {
                app.OpenProject(@"TestData\NodejsProjectData\DragDropTest.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    var folder  = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder");
                    var project = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest");

                    // click on SubItem.js
                    var point = folder.GetClickablePoint();
                    Mouse.MoveTo(point);
                    Mouse.Down(MouseButton.Left);

                    // move to project and hover
                    var projectPoint = project.GetClickablePoint();
                    Mouse.MoveTo(projectPoint);

                    // move back and release
                    Mouse.MoveTo(point);
                    Mouse.Up(MouseButton.Left);

                    Assert.AreNotEqual(null, window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder"));
                }
            }
        }
Exemple #10
0
        public void AddNewFolderLongPathBoundary()
        {
            using (var app = new VisualStudioApp())
            {
                var project = OpenLongFileNameProject(app, 24);

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("01234567891");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN", "01234567891"));

                    var projectLoc  = Path.GetDirectoryName(project.FullName);
                    var checkedPath = Path.Combine(projectLoc, "LongFileNames", "01234567891");

                    Assert.IsTrue(Directory.Exists(checkedPath), checkedPath + " does not exist");
                }
            }
        }
Exemple #11
0
        public void AddNewFolderLongPathTooLong()
        {
            using (var app = new VisualStudioApp())
            {
                var project = OpenLongFileNameProject(app, 24);

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("012345678912");
                    Keyboard.PressAndRelease(Key.Enter);

                    VisualStudioApp.CheckMessageBox("The filename or extension is too long.");
                }
            }
        }
Exemple #12
0
        public void DeleteFile()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteFile.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var programPy = window.WaitForItem("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js");
                    Assert.IsTrue(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js"));
                    AutomationWrapper.Select(programPy);

                    Keyboard.Type(Key.Delete);
                    app.WaitForDialog();
                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "will be deleted permanently");
                    app.WaitForDialogDismissed();

                    window.WaitForItemRemoved("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js");

                    Assert.IsFalse(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js"));
                }
            }
        }
Exemple #13
0
        public void AddNewFolder()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld");
                    AutomationWrapper.Select(projectNode);

                    var startingDirs = new HashSet <string>(Directory.GetDirectories(@"TestData\NodejsProjectData\HelloWorld"), StringComparer.OrdinalIgnoreCase);
                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("MyNewFolder");
                    var curDirs = new HashSet <string>(Directory.GetDirectories(@"TestData\NodejsProjectData\HelloWorld"), StringComparer.OrdinalIgnoreCase);
                    Assert.IsTrue(curDirs.IsSubsetOf(startingDirs) && startingDirs.IsSubsetOf(curDirs), "new directory created" + String.Join(", ", curDirs) + " vs. " + String.Join(", ", startingDirs));

                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "MyNewFolder"));

                    Assert.IsTrue(Directory.Exists(@"TestData\NodejsProjectData\HelloWorld\MyNewFolder"));
                }
            }
        }
Exemple #14
0
        public void CopyPasteFile()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var programPy = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server.js");

                    AutomationWrapper.Select(programPy);

                    Keyboard.ControlC();
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy.js"));

                    AutomationWrapper.Select(programPy);
                    Keyboard.ControlC();
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy (2).js"));
                }
            }
        }
Exemple #15
0
        public void TransferItem()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    string filename, basename;
                    int    i = 0;
                    do
                    {
                        i++;
                        basename = "test" + i + " .js";
                        filename = Path.Combine(Path.GetTempPath(), basename);
                    } while (System.IO.File.Exists(filename));

                    System.IO.File.WriteAllText(filename, "function f() { }");

                    var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

                    using (var dlg = ChooseLocationDialog.FromDte(app)) {
                        dlg.SelectProject("HelloWorld");
                        dlg.OK();
                    }

                    var window = app.OpenSolutionExplorer();
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", basename));

                    Assert.AreEqual(fileWindow.Caption, basename);

                    System.IO.File.Delete(filename);
                }
            }
        }
Exemple #16
0
        public void DeleteLockedFolder()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteLockedFolder.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder");
                    AutomationWrapper.Select(folderNode);

                    var psi = new ProcessStartInfo(
                        Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "system32", "cmd.exe"));
                    psi.WorkingDirectory = Path.Combine(Environment.CurrentDirectory, @"TestData\NodejsProjectData\DeleteLockedFolder\Folder");
                    psi.CreateNoWindow   = true;
                    psi.UseShellExecute  = false;
                    using (var process = System.Diagnostics.Process.Start(psi)) {
                        try {
                            //Ensure the other process started and has time to lock the file
                            System.Threading.Thread.Sleep(1000);
                            Keyboard.Type(Key.Delete);
                            app.WaitForDialog();
                            Keyboard.Type(Key.Enter);
                            System.Threading.Thread.Sleep(500);

                            VisualStudioApp.CheckMessageBox("The process cannot access the file 'Folder' because it is being used by another process.");
                        } finally {
                            process.Kill();
                        }
                    }

                    Assert.IsNotNull(window.FindItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder"));
                }
            }
        }
Exemple #17
0
        public void SaveAs()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\NodejsProjectData\SaveAsUI.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    var solutionTree = app.OpenSolutionExplorer();

                    // open and edit the file
                    var folderNode = solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "server.js");
                    folderNode.SetFocus();
                    Keyboard.PressAndRelease(Key.Enter);

                    var item   = project.ProjectItems.Item("server.js");
                    var window = item.Open();
                    window.Activate();

                    var selection = ((TextSelection)window.Selection);
                    selection.SelectAll();
                    selection.Delete();

                    // save under a new file name
                    var    saveDialog = app.SaveAs();
                    string oldName    = saveDialog.FileName;
                    saveDialog.FileName = "Program2.js";
                    saveDialog.Save();

                    Assert.AreNotEqual(null, solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program2.js"));
                }
            }
        }
Exemple #18
0
        public void DragLeaveFolderTest()
        {
            DebugProject.OpenProject(@"Python.VS.TestData\DragDropTest.sln");

            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            var folder  = window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder");
            var project = window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest");

            // click on SubItem.py
            var point = folder.GetClickablePoint();

            Mouse.MoveTo(point);
            Mouse.Down(MouseButton.Left);

            // move to project and hover
            var projectPoint = project.GetClickablePoint();

            Mouse.MoveTo(projectPoint);
            System.Threading.Thread.Sleep(500);

            // move back and release
            Mouse.MoveTo(point);
            Mouse.Up(MouseButton.Left);

            Assert.AreNotEqual(null, window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder"));
        }
Exemple #19
0
        public void TestPublishFilesControlled()
        {
            var project = DebugProject.OpenProject(@"Python.VS.TestData\PublishTest.sln");

            try {
                string subDir = Guid.NewGuid().ToString();
                project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                string dir = Path.Combine(TestSharePublic, subDir);
                var    app = new VisualStudioApp(VsIdeTestHostContext.Dte);

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                // find Program.py, send copy & paste, verify copy of file is there
                var programPy = window.FindItem("Solution 'PublishTest' (1 project)", "HelloWorld");

                programPy.SetFocus();

                ThreadPool.QueueUserWorkItem(x => VsIdeTestHostContext.Dte.ExecuteCommand("Build.PublishSelection"));
                System.Threading.Thread.Sleep(2000);
                var files = Directory.GetFiles(dir);
                Assert.AreEqual(files.Length, 2);
                files = files.Select(x => Path.GetFileName(x)).ToArray();
                Assert.IsTrue(files.Contains("Program.py"));
                Assert.IsTrue(files.Contains("TextFile.txt"));

                Directory.Delete(dir, true);
            } finally {
                project.Properties.Item("PublishUrl").Value = "";
            }
        }
Exemple #20
0
        public void NewAzureProject()
        {
            using (var app = new VisualStudioApp())
            {
                using (var newProjDialog = app.FileNewProject())
                {
                    newProjDialog.FocusLanguageNode("JavaScript");

                    var azureApp = newProjDialog.ProjectTypes.FindItem(NodejsVisualStudioApp.JavaScriptAzureWebAppTemplate);
                    azureApp.Select();
                    newProjDialog.OK();
                }

                // wait for new solution to load...
                for (int i = 0; i < 40 && app.Dte.Solution.Projects.Count == 0; i++)
                {
                    System.Threading.Thread.Sleep(250);
                }

                app.OpenSolutionExplorer();
                app.SolutionExplorerTreeView.WaitForItem(
                    "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                    app.Dte.Solution.Projects.Item(1).Name,
                    "server.js"
                    );
                app.SolutionExplorerTreeView.WaitForItem(
                    "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                    app.Dte.Solution.Projects.Item(1).Name,
                    "Web.config"
                    );
            }
        }
Exemple #21
0
        public void DragLeaveTest()
        {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\NodejsProjectData\DragDropTest.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                var item    = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubItem.js");
                var project = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest");

                // click on SubItem.js
                var point = item.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Down(MouseButton.Left);

                // move to project and hover
                var projectPoint = project.GetClickablePoint();
                Mouse.MoveTo(projectPoint);

                // move back and release
                Mouse.MoveTo(point);
                Mouse.Up(MouseButton.Left);

                Assert.AreNotEqual(null, window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubItem.js"));
            }
        }
        public void DragDropTest()
        {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\DragDropRelocatedTest.sln");

                app.OpenSolutionExplorer();
                var window = app.SolutionExplorerTreeView;

                var folder = window.FindItem("Solution 'DragDropRelocatedTest' (1 project)", "DragDropTest", "TestFolder", "SubItem.py");
                var point  = folder.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Down(MouseButton.Left);

                var projectItem = window.FindItem("Solution 'DragDropRelocatedTest' (1 project)", "DragDropTest");
                point = projectItem.GetClickablePoint();
                Mouse.MoveTo(point);
                Mouse.Up(MouseButton.Left);

                Assert.AreNotEqual(null, window.WaitForItem("Solution 'DragDropRelocatedTest' (1 project)", "DragDropTest", "SubItem.py"));

                app.Dte.Solution.Close(true);
                // Ensure file was moved and the path was updated correctly.
                var project = app.OpenProject(@"TestData\DragDropRelocatedTest.sln");
                foreach (var item in project.ProjectItems.OfType <OAFileItem>())
                {
                    Assert.IsTrue(File.Exists((string)item.Properties.Item("FullPath").Value), (string)item.Properties.Item("FullPath").Value);
                }
            }
        }
Exemple #23
0
        public void TestPublishFilesImpersonateNoMachineName()
        {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var    project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir  = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUserWithoutMachine;
                        creds.Password = PrivateSharePassword;
                        creds.OK();
                    }

                    System.Threading.Thread.Sleep(2000);

                    using (var helper = new NetUseHelper()) {
                        string dir   = Path.Combine(helper.Drive + "\\", subDir);
                        var    files = WaitForFiles(dir);
                        Assert.AreEqual(1, files.Length);
                        Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                        Directory.Delete(dir, true);
                    }
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
Exemple #24
0
        public void TestPublishReadOnlyFiles()
        {
            var sourceFile = TestData.GetPath(@"TestData\HelloWorld\Program.py");

            Assert.IsTrue(File.Exists(sourceFile), sourceFile + " not found");
            var attributes = File.GetAttributes(sourceFile);

            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");
                try {
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePublic, subDir);

                    File.SetAttributes(sourceFile, attributes | FileAttributes.ReadOnly);

                    app.OpenSolutionExplorer().SelectProject(project);

                    var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

                    Assert.IsNotNull(files, "Timed out waiting for files to publish");
                    Assert.AreEqual(1, files.Length);
                    Assert.AreEqual("Program.py", Path.GetFileName(files[0]));
                    Assert.IsTrue(File.GetAttributes(sourceFile).HasFlag(FileAttributes.ReadOnly), "Source file should be read-only");
                    Assert.IsFalse(File.GetAttributes(files[0]).HasFlag(FileAttributes.ReadOnly), "Published file should not be read-only");

                    Directory.Delete(dir, true);
                } finally {
                    WNetCancelConnection2(TestSharePublic, 0, true);
                    File.SetAttributes(sourceFile, attributes);
                }
            }
        }
Exemple #25
0
        public void TestPublishFilesControlled()
        {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\PublishTest.sln");
                try {
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePublic, subDir);

                    app.OpenSolutionExplorer().SelectProject(project);

                    var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

                    Assert.IsNotNull(files, "Timed out waiting for files to publish");
                    Assert.AreEqual(2, files.Length);
                    AssertUtil.ContainsExactly(
                        files.Select(Path.GetFileName),
                        "Program.py",
                        "TextFile.txt"
                        );

                    Directory.Delete(dir, true);
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
Exemple #26
0
        public void SaveAs()
        {
            var project = DebugProject.OpenProject(@"Python.VS.TestData\SaveAsUI.sln");
            var app     = new VisualStudioApp(VsIdeTestHostContext.Dte);

            app.OpenSolutionExplorer();
            var solutionTree = app.SolutionExplorerTreeView;

            // open and edit the file
            var folderNode = solutionTree.FindItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program.py");

            folderNode.SetFocus();
            Keyboard.PressAndRelease(Key.Enter);

            var item   = project.ProjectItems.Item("Program.py");
            var window = item.Open();

            var selection = ((TextSelection)window.Selection);

            selection.SelectAll();
            selection.Delete();

            // save under a new file name
            var    saveDialog = app.SaveAs();
            string oldName    = saveDialog.FileName;

            saveDialog.FileName = "Program2.py";
            saveDialog.Save();

            Assert.AreNotEqual(null, solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program2.py"));
        }
Exemple #27
0
        public void TransferItem()
        {
            var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln");

            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            string filename, basename;
            int    i = 0;

            do
            {
                i++;
                basename = "test" + i + " .py";
                filename = Path.Combine(Path.GetTempPath(), basename);
            } while (System.IO.File.Exists(filename));

            System.IO.File.WriteAllText(filename, "def f(): pass");

            var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

            app.MoveCurrentFileToProject("HelloWorld");

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", basename));

            Assert.AreEqual(fileWindow.Caption, basename);

            System.IO.File.Delete(filename);
        }
Exemple #28
0
        public void MultiSelectCopyAndPaste()
        {
            DebugProject.OpenProject(@"Python.VS.TestData\DebuggerProject.sln");

            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            var folderNode = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakAllTest.py");

            folderNode.SetFocus();

            Keyboard.Press(Key.LeftShift);
            Keyboard.PressAndRelease(Key.Down);
            Keyboard.PressAndRelease(Key.Down);
            Keyboard.Release(Key.LeftShift);
            Keyboard.ControlC();

            var projectNode = window.FindItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject");

            projectNode.SetFocus();
            Keyboard.ControlV();

            Assert.AreNotEqual(null, window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakAllTest - Copy.py"));
            Assert.AreNotEqual(null, window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakpointTest - Copy.py"));
            Assert.AreNotEqual(null, window.WaitForItem("Solution 'DebuggerProject' (1 project)", "DebuggerProject", "BreakpointTest2 - Copy.py"));
        }
Exemple #29
0
        public void CopyPasteFile()
        {
            var project = DebugProject.OpenProject(@"Python.VS.TestData\HelloWorld.sln");

            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            app.OpenSolutionExplorer();
            var window = app.SolutionExplorerTreeView;

            // find Program.py, send copy & paste, verify copy of file is there
            var programPy = window.FindItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "Program.py");

            programPy.SetFocus();

            Keyboard.ControlC();
            Keyboard.ControlV();

            Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "Program - Copy.py"));

            programPy.SetFocus();
            Keyboard.ControlC();
            Keyboard.ControlV();

            Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "Program - Copy (2).py"));
        }
        public VisualStudioInstance(SolutionFile solution) {
            _solution = solution;
            _app = new VisualStudioApp();
            Project = _app.OpenProject(solution.Filename);

            ThreadHelper.Generic.Invoke(Keyboard.Reset);
            _solutionExplorer = _app.OpenSolutionExplorer();
            SelectSolutionNode();
        }
Exemple #31
0
        public void GlobalIntellisenseProjectReload()
        {
            Window window;

            using (var app = new VisualStudioApp())
            {
                app.OpenProject(Path.GetFullPath(@"TestData\NodeAppWithModule2\NodeAppWithModule.sln"));

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false))
                {
                    app.OpenSolutionExplorer();
                    var projectName = "NodeAppWithModule";
                    var project     = app.SolutionExplorerTreeView.WaitForItem(
                        "Solution '" + projectName + "' (1 project)",
                        projectName);

                    var projectNode = new TreeNode(project);
                    projectNode.SetFocus();

                    System.Threading.Thread.Sleep(2000);

                    app.Dte.ExecuteCommand("Project.UnloadProject");

                    project = app.SolutionExplorerTreeView.WaitForItem(
                        "Solution '" + projectName + "' (0 projects)",
                        projectName + " (unavailable)");

                    projectNode = new TreeNode(project);
                    projectNode.Select();

                    System.Threading.Thread.Sleep(2000);

                    app.Dte.ExecuteCommand("Project.ReloadProject");

                    Assert.IsNotNull(
                        app.SolutionExplorerTreeView.WaitForItem(
                            "Solution '" + projectName + "' (1 project)",
                            projectName,
                            "server.js"
                            ),
                        "project not reloaded"
                        );

                    var openFile = OpenItem(app, "server.js", app.Dte.Solution.Projects.Item(1), out window);

                    openFile.MoveCaret(6, 1);
                    Keyboard.Type("process.");
                    using (var session = openFile.WaitForSession <ICompletionSession>())
                    {
                        var completions = session.Session.CompletionSets.First().Completions.Select(x => x.InsertionText);
                        Assert.IsTrue(completions.Contains("abort"));
                        Assert.IsTrue(completions.Contains("chdir"));
                    }
                }
            }
        }
Exemple #32
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)
                        );
                    }
                }
            }
        }
Exemple #33
0
		public void CreateNewScript() {
			using (var app = new VisualStudioApp()) {
				var project = app.CreateProject(
					RConstants.TemplateLanguageName, RConstants.ProjectTemplate_EmptyProject,
					System.IO.Path.GetTempPath(), "RTestProject");
				app.OpenSolutionExplorer().SelectProject(project);
				using (var newItem = NewItemDialog.FromDte(app)) {
					AutomationWrapper.Select(newItem.ProjectTypes.FindItem("R Script"));
					newItem.FileName = "my-script.r";
					newItem.OK();
				}

				var document = app.GetDocument("my-script.r");
				document.SetFocus();
				document.Type("2 -> a");
				document.Text.Should().Be("2 -> a# R Script");
			}
		}
        internal static void CreateProject(VisualStudioApp app, string languageName, string templateName, string location, string projectName, string expectedProjectItem) {
            using (var newProjDialog = app.FileNewProject()) {
                newProjDialog.FocusLanguageNode(languageName);
                newProjDialog.Location = location;
                newProjDialog.ProjectName = projectName;

                var djangoApp = newProjDialog.ProjectTypes.FindItem(templateName);
                djangoApp.Select();
                newProjDialog.OK();
            }

            // wait for new solution to load...
            for (int i = 0; i < 40 && app.Dte.Solution.Projects.Count == 0; i++) {
                System.Threading.Thread.Sleep(250);
            }

            app.OpenSolutionExplorer().WaitForItem(
                "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                app.Dte.Solution.Projects.Item(1).Name,
                expectedProjectItem
            );
        }
Exemple #35
0
        public void SaveAs() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\SaveAsUI.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var solutionTree = app.OpenSolutionExplorer();

                    // open and edit the file
                    var folderNode = solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "server.js");
                    folderNode.SetFocus();
                    Keyboard.PressAndRelease(Key.Enter);

                    var item = project.ProjectItems.Item("server.js");
                    var window = item.Open();
                    window.Activate();

                    var selection = ((TextSelection)window.Selection);
                    selection.SelectAll();
                    selection.Delete();

                    // save under a new file name
                    var saveDialog = app.SaveAs();
                    string oldName = saveDialog.FileName;
                    saveDialog.FileName = "Program2.js";
                    saveDialog.Save();

                    Assert.AreNotEqual(null, solutionTree.WaitForItem("Solution 'SaveAsUI' (1 project)", "HelloWorld", "Program2.js"));
                }
            }
        }
Exemple #36
0
        public void MultiSelectCopyAndPaste() {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\NodejsProjectData\MultiSelectCopyAndPaste.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server.js");
                    Mouse.MoveTo(folderNode.GetClickablePoint());
                    Mouse.Click();

                    Keyboard.Press(Key.LeftShift);
                    Keyboard.PressAndRelease(Key.Down);
                    Keyboard.PressAndRelease(Key.Down);
                    Keyboard.Release(Key.LeftShift);
                    Keyboard.ControlC();

                    var projectNode = window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste");

                    AutomationWrapper.Select(projectNode);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server - Copy.js"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server2 - Copy.js"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MultiSelectCopyAndPaste' (1 project)", "MultiSelectCopyAndPaste", "server3 - Copy.js"));
                }
            }
        }
Exemple #37
0
        public void TransferItem() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    string filename, basename;
                    int i = 0;
                    do {
                        i++;
                        basename = "test" + i + " .js";
                        filename = Path.Combine(Path.GetTempPath(), basename);
                    } while (System.IO.File.Exists(filename));

                    System.IO.File.WriteAllText(filename, "function f() { }");

                    var fileWindow = app.Dte.ItemOperations.OpenFile(filename);

                    using (var dlg = ChooseLocationDialog.FromDte(app)) {
                        dlg.SelectProject("HelloWorld");
                        dlg.OK();
                    }

                    var window = app.OpenSolutionExplorer();
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", basename));

                    Assert.AreEqual(fileWindow.Caption, basename);

                    System.IO.File.Delete(filename);
                }
            }
        }
Exemple #38
0
        public void DeleteFile() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteFile.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var programPy = window.WaitForItem("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js");
                    Assert.IsTrue(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js"));
                    AutomationWrapper.Select(programPy);

                    Keyboard.Type(Key.Delete);
                    app.WaitForDialog();
                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Ok, "will be deleted permanently");
                    app.WaitForDialogDismissed();

                    window.WaitForItemRemoved("Solution 'DeleteFile' (1 project)", "HelloWorld", "server.js");

                    Assert.IsFalse(File.Exists(@"TestData\NodejsProjectData\DeleteFile\server.js"));
                }
            }
        }
Exemple #39
0
        public void AddNewFolderLongPathBoundary() {
            using (var app = new VisualStudioApp()) {
                var project = OpenLongFileNameProject(app, 24);

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("01234567891");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN", "01234567891"));

                    var projectLoc = Path.GetDirectoryName(project.FullName);
                    var checkedPath = Path.Combine(projectLoc, "LongFileNames", "01234567891");

                    Assert.IsTrue(Directory.Exists(checkedPath), checkedPath + " does not exist");
                }
            }
        }
Exemple #40
0
        public void TestPublishFilesImpersonateNoMachineName() {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUserWithoutMachine;
                        creds.Password = PrivateSharePassword;
                        creds.OK();
                    }

                    System.Threading.Thread.Sleep(2000);

                    using (var helper = new NetUseHelper()) {
                        string dir = Path.Combine(helper.Drive + "\\", subDir);
                        var files = WaitForFiles(dir);
                        Assert.AreEqual(1, files.Length);
                        Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                        Directory.Delete(dir, true);
                    }
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
Exemple #41
0
        public void TestPublishFtp() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");
                string subDir = Guid.NewGuid().ToString();
                string url = TestFtpUrl + "/" + subDir;
                project.Properties.Item("PublishUrl").Value = url;
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                string dir = Path.Combine(FtpValidateDir, subDir);
                Debug.WriteLine(dir);

                app.OpenSolutionExplorer().SelectProject(project);

                app.ExecuteCommand("Build.PublishSelection");
                System.Threading.Thread.Sleep(2000);
                var files = WaitForFiles(dir);
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                // do it again w/ the directories already existing
                File.Delete(files[0]);

                app.OpenSolutionExplorer().SelectProject(project);
                app.ExecuteCommand("Build.PublishSelection");
                files = WaitForFiles(dir);
                Assert.AreEqual(1, files.Length);
                Assert.AreEqual("Program.py", Path.GetFileName(files[0]));

                Directory.Delete(dir, true);
            }
        }
Exemple #42
0
        public void RenameProjectToExisting() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\RenameProjectTestUI.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorld");

                    // rename once, cancel renaming to existing file....
                    AutomationWrapper.Select(projectNode);
                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("HelloWorldExisting");
                    Keyboard.PressAndRelease(Key.Enter);

                    IntPtr dialog = app.WaitForDialog();

                    VisualStudioApp.CheckMessageBox("HelloWorldExisting.njsproj", "overwrite");

                    // rename again, don't cancel...
                    AutomationWrapper.Select(projectNode);
                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("HelloWorldExisting");
                    Keyboard.PressAndRelease(Key.Enter);

                    dialog = app.WaitForDialog();

                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "HelloWorldExisting.njsproj", "overwrite");

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameProjectTestUI' (1 project)", "HelloWorldExisting"));
                }
            }
        }
Exemple #43
0
        public void RenameItemsTest() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\RenameItemsTestUI.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "server.js");

                    // rename once, cancel renaming to existing file....
                    AutomationWrapper.Select(projectNode);
                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("NewName.txt");
                    Keyboard.Type(Key.Delete);  // delete extension left at end
                    Keyboard.Type(Key.Delete);
                    Keyboard.Type(Key.Delete);
                    System.Threading.Thread.Sleep(100);
                    Keyboard.PressAndRelease(Key.Enter);

                    IntPtr dialog = app.WaitForDialog();

                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Cancel, "file name extension");

                    // rename again, don't cancel...
                    AutomationWrapper.Select(projectNode);
                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("NewName.txt");
                    Keyboard.Type(Key.Delete);  // delete extension left at end
                    Keyboard.Type(Key.Delete);
                    Keyboard.Type(Key.Delete);
                    System.Threading.Thread.Sleep(100);
                    Keyboard.PressAndRelease(Key.Enter);

                    dialog = app.WaitForDialog();

                    VisualStudioApp.CheckMessageBox(MessageBoxButton.Yes, "file name extension");

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "NewName.txt"));

                    var subJs = window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "Sub1", "Sub2", "Foo.js");
                    Assert.IsNotNull(subJs);

                    var sub1 = window.FindItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "Sub1");
                    AutomationWrapper.Select(sub1);
                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("FolderName");
                    Keyboard.PressAndRelease(Key.Enter);

                    for (int i = 0; i < 20; i++) {
                        try {
                            if (project.GetIsFolderExpanded("FolderName")) {
                                break;
                            }
                        } catch (ArgumentException) {
                        }
                        System.Threading.Thread.Sleep(100);
                    }

                    Assert.IsTrue(project.GetIsFolderExpanded("FolderName"));
                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'RenameItemsTestUI' (1 project)", "HelloWorld", "FolderName", "Sub2", "Foo.js"));
                }
            }
        }
Exemple #44
0
        public void DeleteLockedFolder() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\DeleteLockedFolder.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var folderNode = window.WaitForItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder");
                    AutomationWrapper.Select(folderNode);

                    var psi = new ProcessStartInfo(
                        Path.Combine(Environment.GetEnvironmentVariable("WINDIR"), "system32", "cmd.exe"));
                    psi.WorkingDirectory = Path.Combine(Environment.CurrentDirectory, @"TestData\NodejsProjectData\DeleteLockedFolder\Folder");
                    psi.CreateNoWindow = true;
                    psi.UseShellExecute = false;
                    using (var process = System.Diagnostics.Process.Start(psi)) {
                        try {
                            //Ensure the other process started and has time to lock the file
                            System.Threading.Thread.Sleep(1000);
                            Keyboard.Type(Key.Delete);
                            app.WaitForDialog();
                            Keyboard.Type(Key.Enter);
                            System.Threading.Thread.Sleep(500);

                            VisualStudioApp.CheckMessageBox("The process cannot access the file 'Folder' because it is being used by another process.");
                        } finally {
                            process.Kill();
                        }
                    }

                    Assert.IsNotNull(window.FindItem("Solution 'DeleteLockedFolder' (1 project)", "DeleteLockedFolder", "Folder"));
                }
            }
        }
Exemple #45
0
        public void AddNewFolderNested() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("FolderX");
                    Keyboard.PressAndRelease(Key.Enter);

                    var folderNode = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "FolderX");

                    Assert.AreNotEqual(null, folderNode, "failed to find folder X");

                    AutomationWrapper.Select(folderNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("FolderY");
                    Keyboard.PressAndRelease(Key.Enter);

                    var innerFolderNode = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "FolderX", "FolderY");

                    Assert.AreNotEqual(null, innerFolderNode, "failed to find folder Y");

                    AutomationWrapper.Select(innerFolderNode);

                    var newItem = project.ProjectItems.Item("FolderX").Collection.Item("FolderY").Collection.AddFromFile(
                        TestData.GetPath(@"TestData\DebuggerProject\BreakpointBreakOn.js")
                    );

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "FolderX", "FolderY", "BreakpointBreakOn.js"), "failed to find added file");
                }
            }
        }
Exemple #46
0
        public void AddNewItemLongPathTooLong() {
            using (var app = new VisualStudioApp()) {
                var project = OpenLongFileNameProject(app, 12);

                var window = app.OpenSolutionExplorer();

                // find server.js, send copy & paste, verify copy of file is there
                var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                AutomationWrapper.Select(projectNode);

                using (var newItem = NewItemDialog.FromDte(app)) {
                    newItem.FileName = "NewJSFile.js";
                    newItem.OK();
                }

                VisualStudioApp.CheckMessageBox("The filename or extension is too long.");
            }
        }
Exemple #47
0
        public void AddNewItemLongPathBoundary() {
            using (var app = new VisualStudioApp()) {
                var project = OpenLongFileNameProject(app, 12);

                var window = app.OpenSolutionExplorer();

                // find server.js, send copy & paste, verify copy of file is there
                var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                AutomationWrapper.Select(projectNode);

                using (var newItem = NewItemDialog.FromDte(app)) {
                    newItem.FileName = "NewJSFil.js";
                    newItem.OK();
                }

                Assert.IsNotNull(window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN", "NewJSFil.js"));
                Assert.IsTrue(File.Exists(Path.Combine(Path.GetDirectoryName(project.FullName), "LongFileNames", "NewJSFil.js")));
            }
        }
Exemple #48
0
        public void AddNewFolderLongPathTooLongCancelEdit() {
            using (var app = new VisualStudioApp()) {
                var project = OpenLongFileNameProject(app, 21);

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'LongFileNames' (1 project)", "LFN");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Escape);

                    VisualStudioApp.CheckMessageBox("The filename or extension is too long.");
                }
            }
        }
Exemple #49
0
        public void TestPublishReadOnlyFiles() {
            var sourceFile = TestData.GetPath(@"TestData\HelloWorld\Program.py");
            Assert.IsTrue(File.Exists(sourceFile), sourceFile + " not found");
            var attributes = File.GetAttributes(sourceFile);

            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");
                try {
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePublic, subDir);

                    File.SetAttributes(sourceFile, attributes | FileAttributes.ReadOnly);

                    app.OpenSolutionExplorer().SelectProject(project);

                    var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);
                    
                    Assert.IsNotNull(files, "Timed out waiting for files to publish");
                    Assert.AreEqual(1, files.Length);
                    Assert.AreEqual("Program.py", Path.GetFileName(files[0]));
                    Assert.IsTrue(File.GetAttributes(sourceFile).HasFlag(FileAttributes.ReadOnly), "Source file should be read-only");
                    Assert.IsFalse(File.GetAttributes(files[0]).HasFlag(FileAttributes.ReadOnly), "Published file should not be read-only");

                    Directory.Delete(dir, true);
                } finally {
                    WNetCancelConnection2(TestSharePublic, 0, true);
                    File.SetAttributes(sourceFile, attributes);
                }
            }
        }
Exemple #50
0
        public void CutPaste() {
            using (var app = new VisualStudioApp()) {

                app.OpenProject(@"TestData\NodejsProjectData\HelloWorld2.sln", expectedProjects: 2);
                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var subItem = window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder", "SubItem.js");
                    AutomationWrapper.Select(subItem);

                    Keyboard.ControlX();

                    var projectNode = window.FindItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2");

                    AutomationWrapper.Select(projectNode);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "SubItem.js"));
                    Assert.AreEqual(null, window.WaitForItemRemoved("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder", "SubItem.js"));
                }
            }
        }
Exemple #51
0
        public void TestPublishFilesControlled() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\PublishTest.sln");
                try {
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePublic, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePublic, subDir);

                    app.OpenSolutionExplorer().SelectProject(project);

                    var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

                    Assert.IsNotNull(files, "Timed out waiting for files to publish");
                    Assert.AreEqual(2, files.Length);
                    AssertUtil.ContainsExactly(
                        files.Select(Path.GetFileName),
                        "Program.py",
                        "TextFile.txt"
                    );

                    Directory.Delete(dir, true);
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
Exemple #52
0
        public void CopyFolderOnToSelf() {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\NodejsProjectData\HelloWorld2.sln", expectedProjects: 2);
                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var folder = window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder");
                    AutomationWrapper.Select(folder);

                    Keyboard.ControlC();
                    AutomationWrapper.Select(folder);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld2' (2 projects)", "HelloWorld2", "TestFolder - Copy"));
                }
            }
        }
Exemple #53
0
        public void TestPublishFilesImpersonateCancelCredentials() {
            WNetCancelConnection2(TestSharePrivate, 0, true);
            using (var app = new VisualStudioApp()) {
                try {
                    var project = app.OpenProject(@"TestData\HelloWorld.sln");
                    string subDir = Guid.NewGuid().ToString();
                    project.Properties.Item("PublishUrl").Value = Path.Combine(TestSharePrivate, subDir);
                    app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");
                    string dir = Path.Combine(TestSharePrivate, subDir);

                    app.OpenSolutionExplorer().SelectProject(project);

                    using (var creds = CredentialsDialog.PublishSelection(app)) {
                        creds.UserName = PrivateShareUser;
                        creds.Password = PrivateSharePasswordIncorrect;
                        creds.Cancel();
                    }

                    var statusBar = app.GetService<IVsStatusbar>(typeof(SVsStatusbar));
                    string text = null;
                    const string expected = "Publish failed: Access to the path";

                    for (int i = 0; i < 10; i++) {
                        ErrorHandler.ThrowOnFailure(statusBar.GetText(out text));

                        if (text.StartsWith(expected)) {
                            break;
                        }
                        System.Threading.Thread.Sleep(1000);
                    }

                    Assert.IsTrue(text.StartsWith(expected), "Expected '{0}', got '{1}'", expected, text);
                } finally {
                    WNetCancelConnection2(TestSharePrivate, 0, true);
                }
            }
        }
Exemple #54
0
        public void DragLeaveFolderTest() {
            using (var app = new VisualStudioApp()) {
                app.OpenProject(@"TestData\NodejsProjectData\DragDropTest.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var folder = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder");
                    var project = window.WaitForItem("Solution 'DragDropTest' (1 project)", "DragDropTest");

                    // click on SubItem.js
                    var point = folder.GetClickablePoint();
                    Mouse.MoveTo(point);
                    Mouse.Down(MouseButton.Left);

                    // move to project and hover
                    var projectPoint = project.GetClickablePoint();
                    Mouse.MoveTo(projectPoint);

                    // move back and release
                    Mouse.MoveTo(point);
                    Mouse.Up(MouseButton.Left);

                    Assert.AreNotEqual(null, window.FindItem("Solution 'DragDropTest' (1 project)", "DragDropTest", "TestFolder2", "SubFolder"));
                }
            }
        }
Exemple #55
0
        public void TestPublishVirtualEnvironment() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\VirtualEnv.sln");
                var dir = TestData.GetTempPath(randomSubPath: true);
                project.Properties.Item("PublishUrl").Value = dir;
                app.OnDispose(() => project.Properties.Item("PublishUrl").Value = "");

                app.OpenSolutionExplorer().SelectProject(project);
                var files = PublishAndWaitForFiles(app, "Build.PublishSelection", dir);

                Assert.IsNotNull(files, "Timed out waiting for files to publish");
                AssertUtil.ContainsAtLeast(
                    files.Select(f => CommonUtils.GetRelativeFilePath(dir, f).ToLowerInvariant()),
                    "env\\include\\pyconfig.h",
                    "env\\lib\\site.py",
                    "env\\scripts\\python.exe",
                    "program.py"
                );

                Directory.Delete(dir, true);
            }
        }
Exemple #56
0
        public void AbsolutePaths() {
            var proj = File.ReadAllText(TestData.GetPath(@"TestData\NodejsProjectData\AbsolutePath\AbsolutePath.njsproj"));
            proj = proj.Replace("[ABSPATH]", TestData.GetPath(@"TestData\NodejsProjectData\AbsolutePath"));
            File.WriteAllText(TestData.GetPath(@"TestData\NodejsProjectData\AbsolutePath\AbsolutePath.njsproj"), proj);


            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\AbsolutePath.sln");

                var window = app.OpenSolutionExplorer();

                // find server.js, send copy & paste, verify copy of file is there
                var programPy = window.WaitForItem("Solution 'AbsolutePath' (1 project)", "AbsolutePath", "server.js");
                Assert.AreNotEqual(null, programPy);
            }
        }
Exemple #57
0
        public void CopyPasteFile() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var programPy = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server.js");

                    AutomationWrapper.Select(programPy);

                    Keyboard.ControlC();
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy.js"));

                    AutomationWrapper.Select(programPy);
                    Keyboard.ControlC();
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "server - Copy (2).js"));
                }
            }
        }
Exemple #58
0
        public void AddNewFolder() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\HelloWorld.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var projectNode = window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld");
                    AutomationWrapper.Select(projectNode);

                    var startingDirs = new HashSet<string>(Directory.GetDirectories(@"TestData\NodejsProjectData\HelloWorld"), StringComparer.OrdinalIgnoreCase);
                    Keyboard.PressAndRelease(Key.F10, Key.LeftCtrl, Key.LeftShift);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.PressAndRelease(Key.Right);
                    Keyboard.PressAndRelease(Key.D);
                    Keyboard.Type("MyNewFolder");
                    var curDirs = new HashSet<string>(Directory.GetDirectories(@"TestData\NodejsProjectData\HelloWorld"), StringComparer.OrdinalIgnoreCase);
                    Assert.IsTrue(curDirs.IsSubsetOf(startingDirs) && startingDirs.IsSubsetOf(curDirs), "new directory created" + String.Join(", ", curDirs) + " vs. " + String.Join(", ", startingDirs));

                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'HelloWorld' (1 project)", "HelloWorld", "MyNewFolder"));

                    Assert.IsTrue(Directory.Exists(@"TestData\NodejsProjectData\HelloWorld\MyNewFolder"));
                }
            }
        }
Exemple #59
0
        public void MoveStartupFile() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\NodejsProjectData\MoveStartupFile.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    // find server.js, send copy & paste, verify copy of file is there
                    var server = window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "server.js");
                    var folder = window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "TestDir");

                    AutomationWrapper.Select(server);
                    Keyboard.ControlX();

                    AutomationWrapper.Select(folder);
                    Keyboard.ControlV();

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'MoveStartupFile' (1 project)", "HelloWorld", "TestDir", "server.js"));

                    Assert.IsTrue(((string)project.Properties.Item("StartupFile").Value).EndsWith("TestDir\\server.js"));
                }
            }
        }
Exemple #60
0
        public void CopyPasteRenameFile() {
            using (var app = new VisualStudioApp()) {
                var project = app.OpenProject(@"TestData\CopyPasteRenameProject\CopyPasteRenameProject.sln");

                using (new NodejsOptionHolder(NodejsPackage.Instance.GeneralOptionsPage, "ShowBrowserAndNodeLabels", false)) {
                    var window = app.OpenSolutionExplorer();

                    var jsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameJavaScript", "app.js");

                    AutomationWrapper.Select(jsFile);

                    Keyboard.ControlC();
                    Keyboard.ControlV();
                    var copiedJsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameJavaScript", "app - Copy.js");
                    Assert.AreNotEqual(null, copiedJsFile);

                    AutomationWrapper.Select(copiedJsFile);

                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("renamed");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameJavaScript", "renamed.js"));


                    var tsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameProjectTypeScript", "app.ts");

                    AutomationWrapper.Select(tsFile);

                    Keyboard.ControlC();
                    Keyboard.ControlV();
                    var copiedTsFile = window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameProjectTypeScript", "app - Copy.ts");
                    Assert.AreNotEqual(null, copiedTsFile);

                    AutomationWrapper.Select(copiedTsFile);

                    Keyboard.PressAndRelease(Key.F2);
                    System.Threading.Thread.Sleep(100);

                    Keyboard.Type("renamed");
                    Keyboard.PressAndRelease(Key.Enter);

                    Assert.AreNotEqual(null, window.WaitForItem("Solution 'CopyPasteRenameProject' (2 projects)", "CopyPasteRenameProjectTypeScript", "renamed.ts"));
                }
            }
        }