Exemplo n.º 1
0
        private void MoveToMissingFolder(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("MoveToMissingFolder",
                    projectType,
                    PropertyGroup(
                        Property("ProjectView", "ShowAllFiles")
                    ),
                    ItemGroup(
                        Folder("Fob", isExcluded: false, isMissing: true),
                        Compile("codefile", isExcluded: false)
                    )
                );

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

                    solution.AssertFileDoesntExist("MoveToMissingFolder", "codefile" + projectType.CodeExtension);
                    solution.AssertFileExists("MoveToMissingFolder", "Fob", "codefile" + projectType.CodeExtension);
                }
            }
        }
Exemplo n.º 2
0
        public void CutRenamePaste() {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("DragDropCopyCutPaste",
                    projectType,
                    ItemGroup(
                        Folder("CutRenamePaste"),
                        Compile("CutRenamePaste\\CutRenamePaste")
                    )
                );

                using (var solution = testDef.Generate().ToMockVs()) {
                    var project = solution.WaitForItem("DragDropCopyCutPaste");
                    var file = solution.WaitForItem("DragDropCopyCutPaste", "CutRenamePaste", "CutRenamePaste" + projectType.CodeExtension);

                    file.Select();
                    solution.ControlX();

                    file.Select();
                    solution.Type(Key.F2);
                    solution.Type("CutRenamePasteNewName");
                    solution.Type(Key.Enter);

                    solution.Sleep(1000);
                    project.Select();
                    solution.ControlV();

                    solution.CheckMessageBox("The source URL 'CutRenamePaste" + projectType.CodeExtension + "' could not be found.");
                }
            }
        }
Exemplo n.º 3
0
        public void ShowAllFilesSymLinks() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesSymLink",
                    projectType,
                    Folder("SubFolder")
                );
                var userDef = new ProjectDefinition(
                    def.Name,
                    projectType,
                    true,
                    Property("ProjectView", "ShowAllFiles")
                );

                var solutionFile = SolutionFile.Generate(def.Name, def, userDef);

                using (System.Diagnostics.Process p = System.Diagnostics.Process.Start("cmd.exe",
                    String.Format("/c mklink /J \"{0}\" \"{1}\"",
                        Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SymFolder"),
                        Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SubFolder")
                    ))) {
                    p.WaitForExit();
                }

                using (System.Diagnostics.Process p = System.Diagnostics.Process.Start("cmd.exe",
                    String.Format("/c mklink /J \"{0}\" \"{1}\"",
                        Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SubFolder\Infinite"),
                        Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SubFolder")
                    ))) {
                    p.WaitForExit();
                }

                try {
                    using (var solution = solutionFile.ToVs()) {
                        Assert.IsNotNull(solution.WaitForItem("ShowAllFilesSymLink", "SymFolder"));

                        // https://pytools.codeplex.com/workitem/1150 - infinite links, not displayed
                        Assert.IsNull(solution.FindItem("ShowAllFilesSymLink", "SubFolder", "Infinite"));

                        File.WriteAllText(
                            Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SubFolder\Foo.txt"),
                            "Hi!"
                        );

                        // https://pytools.codeplex.com/workitem/1152 - watching the sym link folder
                        Assert.IsNotNull(solution.WaitForItem("ShowAllFilesSymLink", "SubFolder", "Foo.txt"));
                        Assert.IsNotNull(solution.WaitForItem("ShowAllFilesSymLink", "SymFolder", "Foo.txt"));
                    }
                } finally {
                    using (System.Diagnostics.Process p = System.Diagnostics.Process.Start("cmd.exe",
                        String.Format("/c rmdir \"{0}\" \"{1}\"",
                            Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SymFolder"),
                            Path.Combine(solutionFile.Directory, @"ShowAllFilesSymLink\SubFolder\Infinite")
                        ))) {
                        p.WaitForExit();
                    }
                }
            }
        }
Exemplo n.º 4
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)
                        );
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void RunWithoutStartupFile() {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("RunWithoutStartupFile", projectType);

                using (var solution = testDef.Generate().ToVs()) {
                    solution.OpenDialogWithDteExecuteCommand("Debug.Start");
                    solution.CheckMessageBox("startup file");

                    solution.OpenDialogWithDteExecuteCommand("Debug.StartWithoutDebugging");
                    solution.CheckMessageBox("startup file");
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Cut item, paste into folder, paste into top-level, 2nd paste should prompt for overwrite
        /// </summary>
        private void MultiPaste(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("HelloWorld",
                    projectType,
                    ItemGroup(
                        Compile("server"),
                        Compile("server2"),
                        Folder("SubFolder")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    var server = solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension);
                    var server2 = solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension);

                    mover(
                        solution,
                        solution.WaitForItem("HelloWorld", "SubFolder"),
                        solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension),
                        solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension)
                    );

                    // paste once, multiple items should be pasted
                    Assert.IsNotNull(solution.WaitForItem("HelloWorld", "SubFolder", "server" + projectType.CodeExtension));
                    Assert.IsNotNull(solution.WaitForItem("HelloWorld", "SubFolder", "server2" + projectType.CodeExtension));

                    solution.SelectSolutionNode();

                    mover(
                        solution,
                        solution.WaitForItem("HelloWorld", "SubFolder"),
                        solution.WaitForItem("HelloWorld", "server" + projectType.CodeExtension),
                        solution.WaitForItem("HelloWorld", "server2" + projectType.CodeExtension)
                    );

                    // paste again, we should get the replace prompts...
                    using (var dialog = solution.WaitForOverwriteFileDialog()) {
                        dialog.Cancel();
                    }

                    // https://pytools.codeplex.com/workitem/1154
                    // and we shouldn't get a second dialog after cancelling...
                    solution.WaitForDialogDismissed();
                }
            }
        }
Exemplo n.º 7
0
        public void ShowAllFilesToggle() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFiles",
                    projectType,
                    Folder("SubFolder"),
                    Compile("SubFolder\\server"),
                    Property("ProjectView", "ProjectFiles")
                );

                using (var solution = def.Generate().ToVs()) {
                    var projectNode = solution.WaitForItem("ShowAllFiles", "SubFolder", "server" + projectType.CodeExtension);
                    AutomationWrapper.Select(projectNode);

                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all

                    Assert.IsTrue(solution.GetProject("ShowAllFiles").GetIsFolderExpanded("SubFolder"));
                }
            }
        }
Exemplo n.º 8
0
        public void CopiedBeforeDragPastedAfterDrop()
        {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("DragDropCopyCutPaste",
                    projectType,
                    ItemGroup(
                        Compile("CopiedBeforeDragPastedAfterDrop"),
                        Compile("DragAndDroppedDuringCopy"),
                        Folder("DragDuringCopyDestination"),
                        Folder("PasteFolder")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    var project = solution.WaitForItem("DragDropCopyCutPaste");
                    Assert.AreNotEqual(null, project);
                    var file = solution.WaitForItem("DragDropCopyCutPaste", "CopiedBeforeDragPastedAfterDrop" + projectType.CodeExtension);
                    Assert.AreNotEqual(null, file);
                    var draggedFile = solution.WaitForItem("DragDropCopyCutPaste", "DragAndDroppedDuringCopy" + projectType.CodeExtension);
                    Assert.AreNotEqual(null, draggedFile);
                    var dragFolder = solution.WaitForItem("DragDropCopyCutPaste", "DragDuringCopyDestination");
                    Assert.AreNotEqual(null, dragFolder);

                    AutomationWrapper.Select(file);
                    solution.ControlC();

                    MoveByMouse(
                        solution,
                        dragFolder,
                        draggedFile
                    );

                    var folder = solution.WaitForItem("DragDropCopyCutPaste", "PasteFolder");
                    AutomationWrapper.Select(folder);
                    solution.ControlV();

                    solution.AssertFileExists("DragDropCopyCutPaste", "PasteFolder", "CopiedBeforeDragPastedAfterDrop" + projectType.CodeExtension);
                    solution.AssertFileExists("DragDropCopyCutPaste", "CopiedBeforeDragPastedAfterDrop" + projectType.CodeExtension);
                }
            }
        }
Exemplo n.º 9
0
        public void BasicProjectTest() {
            var sln = new ProjectDefinition(
                "HelloWorld",
                PythonProject,
                Compile("server", "")
            ).Generate();

            using (var vs = sln.ToMockVs()) {
                Assert.IsNotNull(vs.WaitForItem("HelloWorld", "Python Environments"));
                Assert.IsNotNull(vs.WaitForItem("HelloWorld", "References"));
                Assert.IsNotNull(vs.WaitForItem("HelloWorld", "Search Paths"));
                Assert.IsNotNull(vs.WaitForItem("HelloWorld", "server.py"));
                var view = vs.OpenItem("HelloWorld", "server.py");

                view.Invoke(() => view.Type("import "));

                using (var sh = view.WaitForSession<ICompletionSession>()) {
                    AssertUtil.Contains(sh.Session.Completions(), "sys");
                }
            }
        }
Exemplo n.º 10
0
        public void RenameStartupFile() {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition(
                    "RenameStartupFileFolder",
                    projectType,
                    Folder("Folder"),
                    Compile("Folder\\server"),
                    Property("StartupFile", "Folder\\server" + projectType.CodeExtension)
                );

                using (var solution = testDef.Generate().ToVs()) {
                    var file = solution.GetProject("RenameStartupFileFolder").ProjectItems.Item("Folder").ProjectItems.Item("server" + projectType.CodeExtension);
                    file.Name = "server2" + projectType.CodeExtension;

                    Assert.AreEqual(
                        "server2" + projectType.CodeExtension,
                        Path.GetFileName(
                            (string)solution.GetProject("RenameStartupFileFolder").Properties.Item("StartupFile").Value
                        )
                    );
                }
            }
        }
Exemplo n.º 11
0
        public void RenameStartupFileFolder() {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition(
                    "RenameStartupFileFolder", 
                    projectType,
                    Folder("Folder"),
                    Compile("Folder\\server"),
                    Property("StartupFile", "Folder\\server" + projectType.CodeExtension)
                );

                using (var solution = testDef.Generate().ToVs()) {
                    var folder = solution.GetProject("RenameStartupFileFolder").ProjectItems.Item("Folder");
                    folder.Name = "FolderNew";

                    string startupFile = (string)solution.GetProject("RenameStartupFileFolder").Properties.Item("StartupFile").Value;
                    Assert.IsTrue(
                        startupFile.EndsWith(projectType.Code("FolderNew\\server")),
                        "Expected FolderNew in path, got {0}",
                        startupFile
                    );
                }
            }
        }
Exemplo n.º 12
0
        public void ShowAllFilesRapidChanges2() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesRapidChanges",
                    projectType,
                    Property("ProjectView", "ShowAllFiles")
                );

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

                    HashSet<string> addedItems = new HashSet<string>();
                    for (int i = 0; i < 100; i++) {
                        var filename = Path.Combine(solution.SolutionDirectory, "ShowAllFilesRapidChanges", Path.GetRandomFileName());
                        File.WriteAllText(filename, "");
                        File.Delete(filename);
                        File.WriteAllText(filename, "");
                        addedItems.Add(filename);
                    }

                    // give some time for changes to be processed...
                    System.Threading.Thread.Sleep(10000);

                    foreach (var item in addedItems) {
                        Assert.IsNotNull(solution.WaitForItem("ShowAllFilesRapidChanges", Path.GetFileName(item)), item);
                    }
                }
            }
        }
Exemplo n.º 13
0
        public void ShowAllFilesRapidChanges() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesRapidChanges",
                    projectType,
                    Property("ProjectView", "ShowAllFiles")
                );

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

                    List<string> addedItems = new List<string>();
                    for (int i = 0; i < 1000; i++) {
                        var filename = Path.Combine(solution.SolutionDirectory, "ShowAllFilesRapidChanges", Path.GetRandomFileName());
                        File.WriteAllText(filename, "");
                        File.Delete(filename);
                        addedItems.Add(filename);
                    }

                    foreach (var item in addedItems) {
                        Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesRapidChanges", Path.GetFileName(item)));
                    }
                }
            }
        }
Exemplo n.º 14
0
        public void ShowAllExcludeSelected() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllExcludeSelected",
                    projectType,
                    ItemGroup(
                        Folder("Folder"),
                        Compile("Folder\\File1"),
                        Compile("Folder\\File2")
                    ),
                    Property("ProjectView", "ProjectFiles")
                );

                using (var solution = def.Generate().ToVs()) {
                    solution.WaitForItem("ShowAllExcludeSelected");

                    var file = solution.WaitForItem("ShowAllExcludeSelected", "Folder", "File2" + projectType.CodeExtension);
                    AutomationWrapper.Select(file);
                    solution.ExecuteCommand("Project.ExcludeFromProject");

                    solution.WaitForItemRemoved("ShowAllExcludeSelected", "Folder", "File2" + projectType.CodeExtension);

                    Assert.AreEqual("File1" + projectType.CodeExtension, Path.GetFileName(GetSelectedItemName()));

                    file = solution.WaitForItem("ShowAllExcludeSelected", "Folder", "File1" + projectType.CodeExtension);
                    AutomationWrapper.Select(file);
                    solution.ExecuteCommand("Project.ExcludeFromProject");
                    solution.WaitForItemRemoved("ShowAllExcludeSelected", "Folder", "File1" + projectType.CodeExtension);

                    Assert.AreEqual("Folder", Path.GetFileName(GetSelectedItemName().TrimEnd('\\')));
                }
            }
        }
Exemplo n.º 15
0
        public void CopyDeletePaste() {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("DragDropCopyCutPaste",
                    projectType,
                    ItemGroup(
                        Folder("CopyDeletePaste"),
                        Compile("CopyDeletePaste\\CopyDeletePaste")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    var file = solution.WaitForItem("DragDropCopyCutPaste", "CopyDeletePaste", "CopyDeletePaste" + projectType.CodeExtension);
                    var project = solution.WaitForItem("DragDropCopyCutPaste");

                    AutomationWrapper.Select(file);
                    solution.ControlC();

                    AutomationWrapper.Select(file);
                    solution.Type(Key.Delete);
                    solution.WaitForDialog();

                    solution.Type("\r");

                    solution.WaitForDialogDismissed();

                    solution.WaitForItemRemoved("DragDropCopyCutPaste", "CopyDeletePaste", "CopyDeletePaste" + projectType.CodeExtension);

                    AutomationWrapper.Select(project);
                    solution.ControlV();

                    solution.CheckMessageBox("The source URL 'CopyDeletePaste" + projectType.CodeExtension + "' could not be found.");
                }
            }
        }
Exemplo n.º 16
0
        public void ShowAllMoveNotInProject() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllMoveNotInProject",
                    projectType,
                    ItemGroup(
                        Folder("Folder", isExcluded: true),
                        Folder("Folder\\SubFolder", isExcluded: true),
                        Compile("NotInProject", isExcluded:true),
                        Compile("Folder\\File", isExcluded: true),
                        Content("Folder\\SubFolder\\SubFile.txt", "", isExcluded: true)
                    ),
                    Property("ProjectView", "ShowAllFiles")
                );

                using (var solution = def.Generate().ToVs()) {
                    solution.WaitForItem("ShowAllMoveNotInProject");

                    var file = solution.WaitForItem("ShowAllMoveNotInProject", "NotInProject" + projectType.CodeExtension);
                    AutomationWrapper.Select(file);
                    Keyboard.ControlX();
                    System.Threading.Thread.Sleep(1000);

                    var folder = solution.WaitForItem("ShowAllMoveNotInProject", "Folder");
                    AutomationWrapper.Select(folder);
                    Keyboard.ControlV();

                    Assert.IsNotNull(solution.WaitForItem("ShowAllMoveNotInProject", "Folder", "NotInProject" + projectType.CodeExtension));

                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllMoveNotInProject", "Folder", "NotInProject" + projectType.CodeExtension));

                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing again

                    var subFolder = solution.WaitForItem("ShowAllMoveNotInProject", "Folder", "SubFolder");
                    AutomationWrapper.Select(subFolder);

                    Keyboard.ControlX();
                    System.Threading.Thread.Sleep(1000);
                    var projectNode = solution.WaitForItem("ShowAllMoveNotInProject");
                    AutomationWrapper.Select(projectNode);
                    Keyboard.ControlV();
                    Assert.IsNotNull(solution.WaitForItem("ShowAllMoveNotInProject", "SubFolder"));

                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllMoveNotInProject", "SubFolder"));
                }
            }
        }
Exemplo n.º 17
0
        public void ShowAllFilesDefault() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesDefault",
                    projectType,
                    Folder("SubFolder"),
                    Compile("SubFolder\\server"),
                    Compile("NotInProject", isExcluded: true),
                    Property("ProjectView", "")
                );

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


                    Assert.IsNull(solution.FindItem("ShowAllFilesDefault", "NotInProject" + projectType.CodeExtension));

                    // change setting, UI should be updated
                    solution.ExecuteCommand("Project.ShowAllFiles");

                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesDefault", "NotInProject" + projectType.CodeExtension));

                    // save setting, user project file should be updated
                    solution.GetProject("ShowAllFilesDefault").Save();

                    var projectText = File.ReadAllText(Path.Combine(solution.SolutionDirectory, @"ShowAllFilesDefault\ShowAllFilesDefault" + projectType.ProjectExtension + ".user"));
                    Assert.IsTrue(projectText.Contains("<ProjectView>ShowAllFiles</ProjectView>"));
                }
            }
        }
Exemplo n.º 18
0
        public void ShouldWarnOnRun() {
            var sln = new ProjectDefinition(
                "HelloWorld",
                PythonProject,
                Compile("app", "print \"hello\"")
            ).Generate();

            using (var vs = sln.ToMockVs())
            using (var analyzerChanged = new AutoResetEvent(false)) {
                var project = vs.GetProject("HelloWorld").GetPythonProject();
                project.ProjectAnalyzerChanged += (s, e) => analyzerChanged.Set();

                var v27 = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions {
                    LanguageVersion = new Version(2, 7),
                    PrefixPath = "C:\\Python27",
                    InterpreterPath = "C:\\Python27\\python.exe"
                });
                var v34 = InterpreterFactoryCreator.CreateInterpreterFactory(new InterpreterFactoryCreationOptions {
                    LanguageVersion = new Version(3, 4),
                    PrefixPath = "C:\\Python34",
                    InterpreterPath = "C:\\Python34\\python.exe"
                });

                var uiThread = (UIThreadBase)project.GetService(typeof(UIThreadBase));

                uiThread.Invoke(() => {
                    project.Interpreters.AddInterpreter(v27);
                    project.Interpreters.AddInterpreter(v34);
                });

                project.SetInterpreterFactory(v27);
                Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #1");
                uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
                Assert.IsFalse(project.ShouldWarnOnLaunch, "Should not warn on 2.7");

                project.SetInterpreterFactory(v34);
                Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #2");
                uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
                Assert.IsTrue(project.ShouldWarnOnLaunch, "Expected warning on 3.4");

                project.SetInterpreterFactory(v27);
                Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #3");
                uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
                Assert.IsFalse(project.ShouldWarnOnLaunch, "Expected warning to go away on 2.7");
            }
        }
Exemplo n.º 19
0
 public ProjectDefinition(ProjectType newProjectType, ProjectDefinition wrap)
     : this(wrap.Name, newProjectType, wrap._isUserProject, wrap.Items)
 {
 }
Exemplo n.º 20
0
        public void ShowAllFilesIncludeExclude() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesIncludeExclude",
                    projectType,
                    ItemGroup(
                        Folder("ExcludeFolder1"),
                        Folder("ExcludeFolder2"),
                        Folder("IncludeFolder1", isExcluded: true),
                        Folder("IncludeFolder2", isExcluded: true),
                        Folder("IncludeFolder3", isExcluded: true),
                        Folder("NotOnDiskFolder", isMissing: true)
                    ),
                    ItemGroup(
                        Compile("NotInProject", isExcluded: true),
                        Compile("server"),
                        Compile("NotOnDisk", isMissing: true),
                        Content("ExcludeFolder1\\Item.txt", ""),
                        Content("ExcludeFolder2\\Item.txt", ""),
                        Content("IncludeFolder1\\Item.txt", "", isExcluded: true),
                        Content("IncludeFolder2\\Item.txt", "", isExcluded: true),
                        Content("IncludeFolder2\\Item2.txt", "", isExcluded: true),
                        Content("IncludeFolder3\\Text.txt", "", isExcluded: true),
                        Compile("..\\LinkedFile")
                    ),
                    PropertyGroup(
                        Property("ProjectView", "ShowAllFiles"),
                        StartupFile("server")
                    )
                );

                using (var solution = def.Generate().ToVs()) {
                    var projectNode = solution.WaitForItem("ShowAllFilesIncludeExclude");

                    var excludedFolder = solution.GetProject("ShowAllFilesIncludeExclude").ProjectItems.Item("ExcludeFolder1");
                    var itemTxt = excludedFolder.ProjectItems.Item("Item.txt");
                    var buildAction = itemTxt.Properties.Item("BuildAction");
                    Assert.IsNotNull(buildAction);

                    var notInProject = solution.WaitForItem("ShowAllFilesIncludeExclude", "NotInProject" + projectType.CodeExtension);
                    AutomationWrapper.Select(notInProject);

                    var folder = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1");
                    AutomationWrapper.Select(folder);
                    solution.ExecuteCommand("Project.ExcludeFromProject");

                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "ExcludeFolder1"));

                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all again
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1"));
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1", "Item.txt"));

                    // https://nodejstools.codeplex.com/workitem/250
                    var linkedFile = solution.WaitForItem("ShowAllFilesIncludeExclude", "LinkedFile" + projectType.CodeExtension);
                    AutomationWrapper.Select(linkedFile);
                    solution.ExecuteCommand("Project.ExcludeFromProject");
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "LinkedFile" + projectType.CodeExtension));

                    // https://pytools.codeplex.com/workitem/1153
                    // Shouldn't have a BuildAction property on excluded items
                    try {
                        solution.GetProject("ShowAllFilesIncludeExclude").ProjectItems.Item("ExcludedFolder1").ProjectItems.Item("Item.txt").Properties.Item("BuildAction");
                        Assert.Fail("Excluded item had BuildAction");
                    } catch (ArgumentException) {
                    }

                    var file = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder2", "Item.txt");
                    AutomationWrapper.Select(file);
                    solution.ExecuteCommand("Project.ExcludeFromProject");

                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "ExcludeFolder2", "Item.txt"));
                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all

                    var itemTxtNode = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder2", "Item.txt");
                    Assert.IsNotNull(itemTxtNode);

                    AutomationWrapper.Select(itemTxtNode);

                    // https://pytools.codeplex.com/workitem/1143
                    try {
                        solution.ExecuteCommand("Project.AddNewItem");
                        Assert.Fail("Added a new item on excluded node");
                    } catch (COMException) {
                    }

                    var excludedFolderNode = solution.WaitForItem("ShowAllFilesIncludeExclude", "ExcludeFolder1");
                    Assert.IsNotNull(excludedFolderNode);
                    AutomationWrapper.Select(excludedFolderNode);
                    try {
                        solution.ExecuteCommand("Project.NewFolder");
                        Assert.Fail("Added a new folder on excluded node");
                    } catch (COMException) {
                    }

                    // include
                    folder = solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1");
                    AutomationWrapper.Select(folder);
                    solution.ExecuteCommand("Project.IncludeInProject");
                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1"));
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1", "Item.txt"));

                    // https://nodejstools.codeplex.com/workitem/242
                    // Rename Item.txt on disk
                    File.Move(
                        Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\Item.txt"),
                        Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\ItemNew.txt")
                    );

                    var includedItem = solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1", "Item.txt");
                    AutomationWrapper.Select(includedItem);
                    solution.ExecuteCommand("Project.ExcludeFromProject");

                    // Rename it back
                    File.Move(
                        Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\ItemNew.txt"),
                        Path.Combine(solution.SolutionDirectory, @"ShowAllFilesIncludeExclude\IncludeFolder1\Item.txt")
                    );

                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all

                    // item should be back
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder1", "Item.txt"));

                    folder = solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder2", "Item.txt");
                    AutomationWrapper.Select(folder);
                    solution.ExecuteCommand("Project.IncludeInProject");
                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder2"));
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder2", "Item.txt"));
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "IncludeFolder2", "Item2.txt"));

                    AutomationWrapper.Select(projectNode);
                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all

                    // exclude an item which exists, but is not on disk, it should be removed
                    var notOnDisk = solution.WaitForItem("ShowAllFilesIncludeExclude", "NotOnDisk" + projectType.CodeExtension);
                    AutomationWrapper.Select(notOnDisk);
                    solution.ExecuteCommand("Project.ExcludeFromProject");
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "NotOnDisk" + projectType.CodeExtension));

                    var notOnDiskFolder = solution.WaitForItem("ShowAllFilesIncludeExclude", "NotOnDiskFolder");
                    AutomationWrapper.Select(notOnDiskFolder);
                    solution.ExecuteCommand("Project.ExcludeFromProject");
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "NotOnDiskFolder"));

                    // https://pytools.codeplex.com/workitem/1138
                    var server = solution.FindItem("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension);

                    AutomationWrapper.Select(server);
                    Keyboard.ControlC();
                    System.Threading.Thread.Sleep(1000);

                    var includeFolder3 = solution.FindItem("ShowAllFilesIncludeExclude", "IncludeFolder3");
                    AutomationWrapper.Select(includeFolder3);

                    Keyboard.ControlV();
                    System.Threading.Thread.Sleep(1000);

                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    // folder should now be included
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesIncludeExclude", "IncludeFolder3"));

                    // https://nodejstools.codeplex.com/workitem/250
                    // Excluding the startup item, and then including it again, it should be bold
                    server = solution.FindItem("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension);
                    AutomationWrapper.Select(server);
                    solution.ExecuteCommand("Project.ExcludeFromProject");

                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension));
                    solution.ExecuteCommand("Project.ShowAllFiles"); // start showing all
                    server = solution.FindItem("ShowAllFilesIncludeExclude", "server" + projectType.CodeExtension);
                    AutomationWrapper.Select(server);

                    solution.ExecuteCommand("Project.IncludeInProject");
                    System.Threading.Thread.Sleep(2000);

                    Assert.IsTrue(solution.GetProject("ShowAllFilesIncludeExclude").GetIsItemBolded("server" + projectType.CodeExtension));
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Copy folder to a destination where the folder already exists.  Say don't copy, nothing should be copied.
        /// </summary>
        private void CopyDuplicateFolderName(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("DragDropCopyCutPaste",
                    projectType,
                    ItemGroup(
                        Folder("CopyDuplicateFolderName"),
                        Compile("CopyDuplicateFolderName\\server"),
                        Folder("CopyDuplicateFolderNameTarget"),
                        Folder("CopyDuplicateFolderNameTarget\\CopyDuplicateFolderName")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    mover(
                        solution,
                        solution.WaitForItem("DragDropCopyCutPaste", "CopyDuplicateFolderNameTarget"),
                        solution.WaitForItem("DragDropCopyCutPaste", "CopyDuplicateFolderName")
                    );

                    using (var dialog = solution.WaitForOverwriteFileDialog()) {
                        AssertUtil.Contains(dialog.Text, "This folder already contains a folder called 'CopyDuplicateFolderName'");
                        dialog.No();
                    }

                    solution.AssertFileDoesntExist("DragDropCopyCutPaste", "CopyDuplicateFolderNameTarget", "CopyDuplicateFolderName", "server" + projectType.CodeExtension);
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Cuts 2 files with the same name, answers yes to overwrite them, and
        /// makes sure only one file is left.
        /// </summary>
        /// <param name="mover"></param>
        private void MoveDuplicateFileNameOverwrite(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var project = new ProjectDefinition(
                    "DragDropCopyCutPaste",
                    projectType,
                    ItemGroup(
                        Folder("A"),
                        Folder("B"),
                        Content("quox.txt", "top-level"),
                        Content("A\\quox.txt", "A")
                    )
                );

                using (var solution = project.Generate().ToVs()) {
                    mover(
                        solution,
                        solution.WaitForItem("DragDropCopyCutPaste", "B"),
                        solution.WaitForItem("DragDropCopyCutPaste", "A", "quox.txt"),
                        solution.WaitForItem("DragDropCopyCutPaste", "quox.txt")
                    );

                    using (var dialog = solution.WaitForOverwriteFileDialog()) {
                        AssertUtil.Contains(dialog.Text, "A file with the same name 'quox.txt' already exists.");
                        dialog.Yes();
                    }

                    solution.AssertFileExists("DragDropCopyCutPaste", "B", "quox.txt");
                    solution.AssertFileDoesntExist("DragDropCopyCutPaste", "quox.txt");
                    solution.AssertFileDoesntExist("DragDropCopyCutPaste", "A", "quox.txt");

                    Assert.AreEqual(1, solution.GetProject("DragDropCopyCutPaste").ProjectItems.Item("B").ProjectItems.Count);
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Move item within the project from one location to where it already exists, skipping the move.
        /// </summary>
        private void MoveDuplicateFileNameSkipMove(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("MoveDuplicateFileName",
                    projectType,
                    ItemGroup(
                        Folder("Folder"),
                        Content("textfile.txt", "root"),
                        Content("Folder\\textfile.txt", "Folder")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    mover(
                        solution,
                        solution.FindItem("MoveDuplicateFileName", "Folder"),
                        solution.FindItem("MoveDuplicateFileName", "textfile.txt")
                    );

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

                    solution.WaitForDialogDismissed();

                    solution.AssertFileExistsWithContent("root", "MoveDuplicateFileName", "textfile.txt");
                    solution.AssertFileExistsWithContent("Folder", "MoveDuplicateFileName", "Folder", "textfile.txt");
                }
            }
        }
Exemplo n.º 24
0
        /// <summary>
        /// https://pytools.codeplex.com/workitem/1909
        /// </summary>
        private void ShowAllFilesMoveExcludedItemToExcludedFolder(DragDropCopyCutPaste.MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesMoveExcludedItemToExcludedFolder",
                    projectType,
                    Property("ProjectView", "ShowAllFiles"),
                    Folder("NewFolder1", isExcluded: true),
                    Compile("server", isExcluded: true)
                );

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

                    mover(
                        solution,
                        solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1"),
                        solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder", "server" + projectType.CodeExtension)
                    );

                    Assert.IsNotNull(
                        solution.WaitForItem("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1", "server" + projectType.CodeExtension)
                    );
                    solution.ExecuteCommand("Project.ShowAllFiles"); // stop showing all

                    Assert.IsNull(
                        solution.WaitForItemRemoved("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1")
                    );
                    Assert.IsNull(
                        solution.WaitForItemRemoved("ShowAllFilesMoveExcludedItemToExcludedFolder", "NewFolder1", "server" + projectType.CodeExtension)
                    );
                }
            }
        }
Exemplo n.º 25
0
        public void ShowAllFilesHiddenFiles() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesHiddenFiles",
                    projectType,
                    ItemGroup(
                        Folder("Folder", isExcluded: true),
                        Folder("HiddenFolder", isExcluded: true)
                    ),
                    ItemGroup(
                        Compile("NotInProject", isExcluded: true),
                        Compile("NotInProject2", isExcluded: true),
                        Compile("server"),
                        Content("Folder\\File.txt", "", isExcluded: true),
                        Content("Folder\\File2.txt", "", isExcluded: true),
                        Content("HiddenFolder\\HiddenFile.txt", "", isExcluded: true)
                    ),
                    PropertyGroup(
                        Property("ProjectView", "ShowAllFiles")
                    )
                );

                var solutionFile = def.Generate();
                var file = Path.Combine(solutionFile.Directory, @"ShowAllFilesHiddenFiles\NotInProject" + projectType.CodeExtension);
                File.SetAttributes(
                    file,
                    File.GetAttributes(file) | FileAttributes.Hidden
                );
                file = Path.Combine(solutionFile.Directory, @"ShowAllFilesHiddenFiles\Folder\File.txt");
                File.SetAttributes(
                    file,
                    File.GetAttributes(file) | FileAttributes.Hidden
                );
                file = Path.Combine(solutionFile.Directory, @"ShowAllFilesHiddenFiles\HiddenFolder");
                File.SetAttributes(
                    file,
                    File.GetAttributes(file) | FileAttributes.Hidden
                );


                using (var solution = solutionFile.ToVs()) {
                    var projectNode = solution.WaitForItem("ShowAllFilesHiddenFiles");

                    // hidden files/folders shouldn't be visible
                    Assert.IsNull(solution.FindItem("ShowAllFilesHiddenFiles", "NotInProject" + projectType.CodeExtension));
                    Assert.IsNull(solution.FindItem("ShowAllFilesHiddenFiles", "Folder", "File.txt"));
                    Assert.IsNull(solution.FindItem("ShowAllFilesHiddenFiles", "HiddenFolder"));

                    // but if they change back, they should be
                    file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\NotInProject" + projectType.CodeExtension);
                    File.SetAttributes(
                        file,
                        File.GetAttributes(file) & ~FileAttributes.Hidden
                    );

                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "NotInProject" + projectType.CodeExtension));
                    file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\Folder\File.txt");
                    File.SetAttributes(
                        file,
                        File.GetAttributes(file) & ~FileAttributes.Hidden
                    );

                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "Folder", "File.txt"));
                    file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\HiddenFolder");
                    File.SetAttributes(
                        file,
                        File.GetAttributes(file) & ~FileAttributes.Hidden
                    );
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "HiddenFolder"));

                    // changing non-hidden items to hidden should cause them to be removed
                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "NotInProject2" + projectType.CodeExtension));
                    file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\NotInProject2" + projectType.CodeExtension);
                    File.SetAttributes(
                        file,
                        File.GetAttributes(file) | FileAttributes.Hidden
                    );
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesHiddenFiles", "NotInProject2" + projectType.CodeExtension));

                    Assert.IsNotNull(solution.WaitForItem("ShowAllFilesHiddenFiles", "Folder"));
                    file = Path.Combine(solution.SolutionDirectory, @"ShowAllFilesHiddenFiles\Folder");
                    File.SetAttributes(
                        file,
                        File.GetAttributes(file) | FileAttributes.Hidden
                    );
                    Assert.IsNull(solution.WaitForItemRemoved("ShowAllFilesHiddenFiles", "Folder"));
                }
            }

        }
Exemplo n.º 26
0
        /// <summary>
        /// Drag file from another hierarchy into folder in our hierarchy, item should be added
        ///     Cannot move the folder 'DuplicateFolderName'. A folder with that name already exists in the destination directory.
        /// </summary>
        private void MoveDuplicateFolderName(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("DragDropCopyCutPaste",
                    projectType,
                    ItemGroup(
                        Folder("DuplicateFolderName"),
                        Folder("DuplicateFolderNameTarget"),
                        Folder("DuplicateFolderNameTarget\\DuplicateFolderName")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    mover(
                        solution,
                        solution.WaitForItem("DragDropCopyCutPaste", "DuplicateFolderNameTarget"),
                        solution.WaitForItem("DragDropCopyCutPaste", "DuplicateFolderName")
                    );

                    solution.CheckMessageBox("Cannot move the folder 'DuplicateFolderName'. A folder with that name already exists in the destination directory.");
                }
            }
        }
Exemplo n.º 27
0
        public void ShouldWarnOnRun() {
            var sln = new ProjectDefinition(
                "HelloWorld",
                PythonProject,
                Compile("app", "print \"hello\"")
            ).Generate();

            using (var vs = sln.ToMockVs())
            using (var analyzerChanged = new AutoResetEvent(false)) {
                var project = vs.GetProject("HelloWorld").GetPythonProject();
                project.ProjectAnalyzerChanged += (s, e) => analyzerChanged.Set();

                var uiThread = (UIThreadBase)project.GetService(typeof(UIThreadBase));
                var interpreters = ((IComponentModel)project.GetService(typeof(SComponentModel)))
                    .GetService<IInterpreterRegistryService>()
                    .Interpreters;
                
                var v27 = interpreters.Where(x => x.Configuration.Id == "Global|PythonCore|2.7|x86").First();
                var v34 = interpreters.Where(x => x.Configuration.Id == "Global|PythonCore|3.4|x86").First();
                var interpOptions = (UIThreadBase)project.GetService(typeof(IComponentModel));

                uiThread.Invoke(() => {
                    project.AddInterpreter(v27.Configuration.Id);
                    project.AddInterpreter(v34.Configuration.Id);
                });

                project.SetInterpreterFactory(v27);
                Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #1");
                uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
                Assert.IsFalse(project.ShouldWarnOnLaunch, "Should not warn on 2.7");

                project.SetInterpreterFactory(v34);
                Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #2");
                uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
                Assert.IsTrue(project.ShouldWarnOnLaunch, "Expected warning on 3.4");

                project.SetInterpreterFactory(v27);
                Assert.IsTrue(analyzerChanged.WaitOne(10000), "Timed out waiting for analyzer change #3");
                uiThread.Invoke(() => project.GetAnalyzer()).WaitForCompleteAnalysis(_ => true);
                Assert.IsFalse(project.ShouldWarnOnLaunch, "Expected warning to go away on 2.7");
            }
        }
Exemplo n.º 28
0
        /// <summary>
        /// Cut 2 items, paste where they exist, skip pasting the 1st one but paste the 2nd.
        /// 
        /// The 1st item shouldn't be removed from the parent hierarchy, the 2nd should, and only the 2nd item should be overwritten.
        /// </summary>
        private void MoveDuplicateFileNamesFoldersSkipOne(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("MoveDuplicateFileName",
                    projectType,
                    ItemGroup(
                        Folder("Source"),
                        Content("Source\\textfile1.txt", "source1"),
                        Content("Source\\textfile2.txt", "source2"),
                        
                        Folder("Target"),
                        Content("Target\\textfile1.txt", "target1"),
                        Content("Target\\textfile2.txt", "target2")
                    )
                );

                using (var solution = testDef.Generate().ToVs()) {
                    mover(
                        solution,
                        solution.FindItem("MoveDuplicateFileName", "Target"),
                        solution.FindItem("MoveDuplicateFileName", "Source", "textfile1.txt"),
                        solution.FindItem("MoveDuplicateFileName", "Source", "textfile2.txt")
                    );

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

                    System.Threading.Thread.Sleep(1000);

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

                    solution.WaitForDialogDismissed();

                    solution.AssertFileExistsWithContent("source1", "MoveDuplicateFileName", "Source", "textfile1.txt");
                    solution.AssertFileDoesntExist("MoveDuplicateFileName", "textfile2.txt");
                    solution.AssertFileExistsWithContent("target1", "MoveDuplicateFileName", "Target", "textfile1.txt");
                    solution.AssertFileExistsWithContent("source2", "MoveDuplicateFileName", "Target", "textfile2.txt");
                }
            }
        }
Exemplo n.º 29
0
        private static ProjectDefinition MakeBasicProject(ProjectType projectType) {
            var def = new ProjectDefinition(
                "ShowAllFiles",
                projectType,
                ItemGroup(
                    Folder("Folder", isExcluded: true),
                    Folder("Folder\\SubFolder", isExcluded: true),
                    Content("Folder\\SubFolder\\SubFile.txt", "", isExcluded: true),
                    Content("Folder\\SubFolder\\File.txt", "", isExcluded: true),
                    Compile("NotInProject", isExcluded: true),
                    Compile("Folder\\File", isExcluded: true),
                    Content("Folder\\File.txt", "", isExcluded: true),
                    Compile("server"),
                    Content("ShowAllFiles.v11.suo", "", isExcluded: true),
                    Folder("..\\MovedIntoShowAllFiles", isExcluded: true),
                    Content("..\\MovedIntoShowAllFiles\\Text.txt", "", isExcluded: true)
                ),
                Property("ProjectView", "ShowAllFiles")
            );

            return def;
        }
Exemplo n.º 30
0
        private void MoveExcludedFolder(MoveDelegate mover) {
            foreach (var projectType in ProjectTypes) {
                var testDef = new ProjectDefinition("MoveExcludedFolder",
                    projectType,
                    PropertyGroup(
                        Property("ProjectView", "ShowAllFiles")
                    ),
                    ItemGroup(
                        Folder("Fob", isExcluded: true),
                        Folder("Fob\\Oar", isExcluded: true),
                        Folder("Baz", isExcluded: true)
                    )
                );

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

                    solution.AssertFolderDoesntExist("MoveExcludedFolder", "Fob");
                    solution.AssertFolderExists("MoveExcludedFolder", "Baz", "Fob");
                }
            }
        }
Exemplo n.º 31
0
        public void ShowAllFilesLinked() {
            foreach (var projectType in ProjectTypes) {
                var def = new ProjectDefinition(
                    "ShowAllFilesLinked",
                    projectType,
                    Compile("..\\File"),
                    Folder("SubFolder"),
                    Compile("..\\LinkedFile").Link("SubFolder\\LinkedFile"),
                    Property("ProjectView", "ProjectFiles")
                );

                using (var solution = def.Generate().ToVs()) {
                    var linkedNode = solution.WaitForItem("ShowAllFilesLinked", "File" + projectType.CodeExtension);
                    AutomationWrapper.Select(linkedNode);
                    Keyboard.ControlC();

                    var subFolder = solution.WaitForItem("ShowAllFilesLinked", "SubFolder");
                    AutomationWrapper.Select(subFolder);

                    Keyboard.ControlV();
                    VisualStudioApp.CheckMessageBox("Cannot copy linked files within the same project. You cannot have more than one link to the same file in a project.");

                    linkedNode = solution.WaitForItem("ShowAllFilesLinked", "SubFolder", "LinkedFile" + projectType.CodeExtension);
                    AutomationWrapper.Select(linkedNode);

                    Keyboard.ControlX();

                    var projectNode = solution.WaitForItem("ShowAllFilesLinked");
                    AutomationWrapper.Select(projectNode);

                    Keyboard.ControlV();
                    solution.GetProject("ShowAllFilesLinked").Save();

                    var text = File.ReadAllText(Path.Combine(solution.SolutionDirectory, @"ShowAllFilesLinked\ShowAllFilesLinked" + projectType.ProjectExtension));
                    Assert.IsTrue(text.IndexOf("<Link>LinkedFile" + projectType.CodeExtension + "</Link>") != -1);
                }
            }
        }