Beispiel #1
0
        public void TestProjectProperties()
        {
            var filename = Path.Combine(TestData.GetTempPath(), Path.GetRandomFileName());

            var project = Project("ProjectProperties",
                Compile("server"),
                Property("StartupFile", "server.js")
            );

            using (var solution = project.Generate().ToVs()) {
                var projectNode = solution.WaitForItem("ProjectProperties");
                AutomationWrapper.Select(projectNode);

                solution.App.Dte.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");
                AutomationElement doc = null;
                for (int i = 0; i < 10; i++) {
                    doc = solution.App.GetDocumentTab("ProjectProperties");
                    if (doc != null) {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
                Assert.IsNotNull(doc, "Failed to find project properties tab");

                var nodeExeArguments = new TextBox(
                        new AutomationWrapper(doc).FindByAutomationId("_nodeArguments")
                    );
                var debuggerMachineName = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_debuggerMachineName")
                );

                debuggerMachineName.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("10.11.22.33");

                nodeExeArguments.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("--use-logger --debug");

                solution.App.Dte.ExecuteCommand("File.SaveAll");

                var projFile = File.ReadAllText(solution.Project.FullName);
                Assert.AreNotEqual(-1, projFile.IndexOf("<DebuggerMachineName>10.11.22.33</DebuggerMachineName>"));
                Assert.AreNotEqual(-1, projFile.IndexOf("<NodeExeArguments>--use-logger --debug</NodeExeArguments>"));
            }
        }
        public void ProjectProperties() {
            var filename = Path.Combine(TestData.GetTempPath(), Path.GetRandomFileName());

            var project = Project("ProjectProperties",
                Compile("server"),
                Property(NodeProjectProperty.Environment, "fob=1\r\nbar=2;3\nbaz=4"),
                Property(NodeProjectProperty.DebuggerPort, "1234"),
                Property(CommonConstants.StartupFile, "server.js")
            );

            using (var solution = project.Generate().ToVs()) {
                var projectNode = solution.WaitForItem("ProjectProperties");
                AutomationWrapper.Select(projectNode);

                solution.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");
                AutomationElement doc = null;
                for (int i = 0; i < 10; i++) {
                    doc = ((VisualStudioInstance)solution).App.GetDocumentTab("ProjectProperties");
                    if (doc != null) {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }
                Assert.IsNotNull(doc, "Failed to find project properties tab");

                var debuggerPort =
                    new TextBox(
                        new AutomationWrapper(doc).FindByAutomationId("_debuggerPort")
                    );
                var envVars = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_envVars")
                );

                Assert.AreEqual(debuggerPort.Value, "1234");
                Assert.AreEqual(envVars.Value, "fob=1\r\nbar=2;3\r\nbaz=4");

                debuggerPort.Value = "2468";

                // Multi-line text box does not support setting value via automation.
                envVars.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type("fob=0\nbar=0;0\nbaz=0");

                solution.ExecuteCommand("File.SaveAll");

                var projFile = File.ReadAllText(solution.GetProject("ProjectProperties").FullName);
                Assert.AreNotEqual(-1, projFile.IndexOf("<DebuggerPort>2468</DebuggerPort>"));
                Assert.AreNotEqual(-1, projFile.IndexOf("<Environment>fob=0\r\nbar=0;0\r\nbaz=0</Environment>"));
            }
        }
Beispiel #3
0
        public void InstallUninstallPackage() {
            using (var app = new PythonVisualStudioApp())
            using (var dis = Init(app)) {
                var project = CreateTemporaryProject(app);

                string envName;
                var env = app.CreateVirtualEnvironment(project, out envName);
                env.Select();

                using (var installPackage = AutomationDialog.FromDte(app, "Python.InstallPackage")) {
                    var packageName = new TextBox(installPackage.FindByAutomationId("Name"));
                    packageName.SetValue("azure==0.6.2");
                    installPackage.ClickButtonAndClose("OK", nameIsAutomationId: true);
                }

                var azure = app.SolutionExplorerTreeView.WaitForChildOfProject(
                    project,
                    SR.GetString(SR.Environments),
                    envName,
                    "azure (0.6.2)"
                );

                azure.Select();

                using (var confirmation = AutomationDialog.FromDte(app, "Edit.Delete")) {
                    confirmation.OK();
                }

                app.SolutionExplorerTreeView.WaitForChildOfProjectRemoved(
                    project,
                    SR.GetString(SR.Environments),
                    envName,
                    "azure (0.6.2)"
                );
            }
        }
Beispiel #4
0
        public void Breakpoint()
        {
            using (var app = new VisualStudioApp())
            {
                var project = app.OpenProject(@"TestData\HelloWorld.sln");

                TargetInfo ti = GetTargetInfo();

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

                Assert.IsFalse(0 == app.Dte.Solution.Projects.Count);

                // Set platform
                foreach (SolutionConfiguration2 solConfiguration2 in app.Dte.Solution.SolutionBuild.SolutionConfigurations)
                {
                    if(String.Equals(solConfiguration2.PlatformName, ti.Plat, StringComparison.Ordinal))
                    {
                        solConfiguration2.Activate();
                        break;
                    }
                }

                // Open project properties
                var item = app.SolutionExplorerTreeView.WaitForItem(
                    "Solution '" + app.Dte.Solution.Projects.Item(1).Name + "' (1 project)",
                    app.Dte.Solution.Projects.Item(1).Name
                );
                AutomationWrapper.Select(item);

                app.Dte.ExecuteCommand("ClassViewContextMenus.ClassViewMultiselectProjectReferencesItems.Properties");

                AutomationElement doc = null;
                for (int i = 0; i < 10; i++)
                {
                    doc = app.GetDocumentTab("HelloWorld.njsproj");
                    if (doc != null)
                    {
                        break;
                    }
                    System.Threading.Thread.Sleep(1000);
                }

                Assert.IsNotNull(doc, "Failed to find project properties tab");

                // Enter IP address of target machine
                var debuggerMachineName = new TextBox(
                    new AutomationWrapper(doc).FindByAutomationId("_debuggerMachineName")
                );
                debuggerMachineName.SetFocus();
                Keyboard.ControlA();
                Keyboard.Backspace();
                Keyboard.Type(ti.IP);
                app.Dte.ExecuteCommand("File.SaveAll");

                // Build project
                app.Dte.Solution.SolutionBuild.Build(true);

                // Add breakpoint
                app.Dte.Debugger.Breakpoints.Add(String.Empty, "server.js", 3, 1, String.Empty,
                    dbgBreakpointConditionType.dbgBreakpointConditionTypeWhenTrue, String.Empty,
                    String.Empty, 1, String.Empty, 1, dbgHitCountType.dbgHitCountTypeNone);

                // F5
                app.Dte.ExecuteCommand("Debug.Start");

                // Check that breakpoint is hit
                app.WaitForMode(dbgDebugMode.dbgBreakMode);
                Assert.IsTrue(app.Dte.ActiveDocument.Name.Contains("server.js"));
                Assert.IsTrue((app.Dte.ActiveDocument.Object("TextDocument") as TextDocument).Selection.ActivePoint.Line == 3);
            }
        }