Example #1
0
        public void SourceControlExcludedFilesNotPresent()
        {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes)
                {
                    using (var solution = SourceControlProject(projectType).Generate()) {
                        // close any projects before switching source control...
                        app.Dte.Solution.Close();

                        app.SelectSourceControlProvider("Test Source Provider");

                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        foreach (var curFile in sccProject.Files)
                        {
                            Assert.IsFalse(curFile.Key.EndsWith("ExcludedFile" + projectType.CodeExtension), "found excluded file");
                        }
                    }
                }

                app.Dte.Solution.Close();
                app.SelectSourceControlProvider("None");
            }
        }
Example #2
0
        public void SourceControlRenameFolder()
        {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes)
                {
                    // close any projects before switching source control...
                    app.Dte.Solution.Close();

                    app.SelectSourceControlProvider("Test Source Provider");

                    TestSccProvider.DocumentEvents.Clear();

                    using (var solution = SourceControlProject(projectType).Generate()) {
                        try {
                            var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                            project.ProjectItems.Item("TestFolder").Name = "Renamed";

                            AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                                 OnQueryRenameFiles("TestFolder\\", "Renamed\\", VSQUERYRENAMEFILEFLAGS_Directory),
                                                 OnAfterRenameFiles("TestFolder\\", "Renamed", VSRENAMEFILEFLAGS_Directory)
                                                 );
                            app.Dte.Solution.Close();
                        } finally {
                            app.SelectSourceControlProvider("None");
                        }
                    }
                }
            }
        }
Example #3
0
        public void SourceControlNoControl()
        {
            using (var app = new VisualStudioApp()) {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                DontExpectSourceControl();

                foreach (var projectType in ProjectTypes)
                {
                    var testDef = NoSourceControlProject(projectType);
                    using (var solution = testDef.Generate()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0)
                        {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
Example #4
0
        public void SourceControlGlyphChanged()
        {
            using (var app = new VisualStudioApp())
            {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");

                foreach (var projectType in ProjectTypes)
                {
                    var testDef = SourceControlProject(projectType);
                    using (var solution = testDef.Generate())
                    {
                        var project = app.OpenProject(solution.Filename);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        Microsoft.TestSccPackage.FileInfo fileInfo = null;
                        foreach (var curFile in sccProject.Files)
                        {
                            if (curFile.Key.EndsWith("Program" + projectType.CodeExtension))
                            {
                                fileInfo = curFile.Value;
                                break;
                            }
                        }
                        Assert.IsNotNull(fileInfo);

                        fileInfo.GlyphChanged(VsStateIcon.STATEICON_CHECKEDOUTEXCLUSIVEOTHER);

                        var programPy = project.ProjectItems.Item("Program" + projectType.CodeExtension);
                        Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "CHECKEDOUTEXCLUSIVEOTHER");

                        fileInfo.StateIcon = VsStateIcon.STATEICON_READONLY;
                        sccProject.AllGlyphsChanged();

                        Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "READONLY");

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0)
                        {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
Example #5
0
        public void AddExistingItem()
        {
            using (var app = new VisualStudioApp()) {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                foreach (var projectType in ProjectTypes)
                {
                    var testDef = SourceControlProject(projectType);

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

                        var project  = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);
                        var fileName = projectType.Code(@"ExcludedFile");

                        using (var newItem = AddExistingItemDialog.FromDte(app)) {
                            newItem.FileName = fileName;
                            newItem.OK();
                        }

                        System.Threading.Thread.Sleep(250);

                        Assert.IsNotNull(project.ProjectItems.Item(fileName));
                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                             OnQueryAddFiles(fileName),
                                             OnAfterAddFilesEx(fileName)
                                             );
                    }
                }
            }
        }
Example #6
0
        public void SourceControlGlyphChanged()
        {
            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            // close any projects before switching source control...
            VsIdeTestHostContext.Dte.Solution.Close();

            app.SelectSourceControlProvider("Test Source Provider");

            var project = DebugProject.OpenProject(@"Python.VS.TestData\SourceControl.sln");

            Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
            var      sccProject = TestSccProvider.LoadedProjects.First();
            FileInfo fileInfo   = null;

            foreach (var curFile in sccProject.Files)
            {
                if (curFile.Key.EndsWith("Program.py"))
                {
                    fileInfo = curFile.Value;
                    break;
                }
            }
            Assert.AreNotEqual(null, fileInfo);

            fileInfo.GlyphChanged(VsStateIcon.STATEICON_CHECKEDOUTEXCLUSIVEOTHER);

            var programPy = project.ProjectItems.Item("Program.py");

            Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "CHECKEDOUTEXCLUSIVEOTHER");

            fileInfo.StateIcon = VsStateIcon.STATEICON_READONLY;
            sccProject.AllGlyphsChanged();

            Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "READONLY");

            app.Dte.Solution.Close();

            Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
            if (TestSccProvider.Failures.Count != 0)
            {
                Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
            }

            app.SelectSourceControlProvider("None");
        }
Example #7
0
        public void BasicSourceControl()
        {
            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 = SourceControlProject(projectType);

                    using (var solution = testDef.Generate())
                    {
                        var project = app.OpenProject(solution.Filename);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);

                        TestSccProvider.ExpectedAuxPath     = null;
                        TestSccProvider.ExpectedLocalPath   = null;
                        TestSccProvider.ExpectedProvider    = null;
                        TestSccProvider.ExpectedProjectName = null;

                        TestSccProvider.LoadedProjects.First().SccProject.SetSccLocation(
                            "NewProjectName",
                            "NewAuxPath",
                            "NewLocalPath",
                            "NewProvider"
                            );

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0)
                        {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
Example #8
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)
                                             );
                    }
                }
            }
        }
Example #9
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)
                        );
                    }
                }
            }
        }
Example #10
0
        public void SourceControl()
        {
            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            // close any projects before switching source control...
            VsIdeTestHostContext.Dte.Solution.Close();

            app.SelectSourceControlProvider("Test Source Provider");

            TestSccProvider.ExpectedAuxPath     = "AuxPath";
            TestSccProvider.ExpectedLocalPath   = "LocalPath";
            TestSccProvider.ExpectedProvider    = "TestProvider";
            TestSccProvider.ExpectedProjectName = "HelloWorld";

            var project = DebugProject.OpenProject(@"Python.VS.TestData\SourceControl.sln");

            Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);

            TestSccProvider.ExpectedAuxPath     = null;
            TestSccProvider.ExpectedLocalPath   = null;
            TestSccProvider.ExpectedProvider    = null;
            TestSccProvider.ExpectedProjectName = null;

            TestSccProvider.LoadedProjects.First().SccProject.SetSccLocation(
                "NewProjectName",
                "NewAuxPath",
                "NewLocalPath",
                "NewProvider"
                );

            app.Dte.Solution.Close();

            Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
            if (TestSccProvider.Failures.Count != 0)
            {
                Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
            }

            app.SelectSourceControlProvider("None");
        }
Example #11
0
        public void SourceControlNoControl()
        {
            var app = new VisualStudioApp(VsIdeTestHostContext.Dte);

            // close any projects before switching source control...
            VsIdeTestHostContext.Dte.Solution.Close();

            app.SelectSourceControlProvider("Test Source Provider");

            var project = DebugProject.OpenProject(@"Python.VS.TestData\NoSourceControl.sln");

            Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);

            app.Dte.Solution.Close();

            Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
            if (TestSccProvider.Failures.Count != 0)
            {
                Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
            }

            app.SelectSourceControlProvider("None");
        }
Example #12
0
        public void IncludeInProject()
        {
            using (var app = new VisualStudioApp())
            {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                foreach (var projectType in ProjectTypes)
                {
                    var testDef = SourceControlProject(projectType);

                    using (var solution = testDef.Generate().ToVs())
                    {
                        TestSccProvider.DocumentEvents.Clear();
                        var project  = app.OpenProject(solution.SolutionFilename);
                        var window   = app.OpenSolutionExplorer();
                        var fileName = projectType.Code(@"ExcludedFile");

                        // Try to select the file.  If it throws, it is likely the issue was that we weren't showing all files.
                        try
                        {
                            window.WaitForChildOfProject(project, fileName).Select();
                        }
                        catch (Exception)
                        {
                            // Show all files so we can see the excluded item if we previously couldn't
                            solution.ExecuteCommand("Project.ShowAllFiles");
                            window.WaitForChildOfProject(project, fileName).Select();
                        }

                        solution.ExecuteCommand("Project.IncludeInProject");

                        System.Threading.Thread.Sleep(250);

                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                             OnQueryAddFiles(fileName),
                                             OnAfterAddFilesEx(fileName)
                                             );
                    }
                }
            }
        }
Example #13
0
        public void RemoveItem()
        {
            using (var app = new VisualStudioApp())
            {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                foreach (var projectType in ProjectTypes)
                {
                    var testDef = SourceControlProject(projectType);

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

                        var project  = app.OpenProject(solution.Filename);
                        var window   = app.OpenSolutionExplorer();
                        var fileName = "Program" + projectType.CodeExtension;
                        var program  = window.WaitForChildOfProject(project, fileName);

                        program.Select();

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

                        window.WaitForChildOfProjectRemoved(project, fileName);

                        var projectDir = Path.GetDirectoryName(project.FullName);

                        AssertDocumentEvents(projectDir,
                                             OnQueryRemoveFiles(fileName),
                                             OnAfterRemoveFiles(fileName)
                                             );
                    }
                }
            }
        }
Example #14
0
        public void SourceControlRenameFolder() {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes) {
                    // close any projects before switching source control...
                    app.Dte.Solution.Close();

                    app.SelectSourceControlProvider("Test Source Provider");

                    TestSccProvider.DocumentEvents.Clear();

                    using (var solution = SourceControlProject(projectType).Generate()) {
                        try {
                            var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                            project.ProjectItems.Item("TestFolder").Name = "Renamed";

                            AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                                OnQueryRenameFiles("TestFolder\\", "Renamed\\", VSQUERYRENAMEFILEFLAGS_Directory),
                                OnAfterRenameFiles("TestFolder\\", "Renamed", VSRENAMEFILEFLAGS_Directory)
                            );
                            app.Dte.Solution.Close();
                        } finally {
                            app.SelectSourceControlProvider("None");
                        }
                    }
                }
            }
        }
Example #15
0
        public void SourceControlExcludedFilesNotPresent() {
            using (var app = new VisualStudioApp()) {
                foreach (var projectType in ProjectTypes) {
                    using (var solution = SourceControlProject(projectType).Generate()) {
                        // close any projects before switching source control...
                        app.Dte.Solution.Close();

                        app.SelectSourceControlProvider("Test Source Provider");

                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        foreach (var curFile in sccProject.Files) {
                            Assert.IsFalse(curFile.Key.EndsWith("ExcludedFile" + projectType.CodeExtension), "found excluded file");
                        }
                    }
                }

                app.Dte.Solution.Close();
                app.SelectSourceControlProvider("None");
            }
        }
Example #16
0
        public void SourceControlNoControl() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                DontExpectSourceControl();

                foreach (var projectType in ProjectTypes) {
                    var testDef = NoSourceControlProject(projectType);
                    using (var solution = testDef.Generate()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0) {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
Example #17
0
        public void SourceControlGlyphChanged() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");

                foreach (var projectType in ProjectTypes) {
                    var testDef = SourceControlProject(projectType);
                    using (var solution = testDef.Generate()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);
                        var sccProject = TestSccProvider.LoadedProjects.First();
                        Microsoft.TestSccPackage.FileInfo fileInfo = null;
                        foreach (var curFile in sccProject.Files) {
                            if (curFile.Key.EndsWith("Program" + projectType.CodeExtension)) {
                                fileInfo = curFile.Value;
                                break;
                            }
                        }
                        Assert.IsNotNull(fileInfo);

                        fileInfo.GlyphChanged(VsStateIcon.STATEICON_CHECKEDOUTEXCLUSIVEOTHER);

                        var programPy = project.ProjectItems.Item("Program" + projectType.CodeExtension);
                        Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "CHECKEDOUTEXCLUSIVEOTHER");

                        fileInfo.StateIcon = VsStateIcon.STATEICON_READONLY;
                        sccProject.AllGlyphsChanged();

                        Assert.AreEqual(programPy.Properties.Item("SourceControlStatus").Value, "READONLY");

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0) {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
Example #18
0
        public void BasicSourceControl() {
            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 = SourceControlProject(projectType);

                    using (var solution = testDef.Generate()) {
                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);

                        Assert.AreEqual(1, TestSccProvider.LoadedProjects.Count);

                        TestSccProvider.ExpectedAuxPath = null;
                        TestSccProvider.ExpectedLocalPath = null;
                        TestSccProvider.ExpectedProvider = null;
                        TestSccProvider.ExpectedProjectName = null;

                        TestSccProvider.LoadedProjects.First().SccProject.SetSccLocation(
                            "NewProjectName",
                            "NewAuxPath",
                            "NewLocalPath",
                            "NewProvider"
                        );

                        app.Dte.Solution.Close();

                        Assert.AreEqual(0, TestSccProvider.LoadedProjects.Count);
                        if (TestSccProvider.Failures.Count != 0) {
                            Assert.Fail(String.Join(Environment.NewLine, TestSccProvider.Failures));
                        }

                        app.SelectSourceControlProvider("None");
                    }
                }
            }
        }
Example #19
0
        public void RemoveItem() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                foreach (var projectType in ProjectTypes) {
                    var testDef = SourceControlProject(projectType);

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

                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);
                        var window = app.SolutionExplorerTreeView;
                        var fileName = "Program" + projectType.CodeExtension;
                        var program = window.WaitForChildOfProject(project, fileName);

                        program.Select();

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

                        window.WaitForChildOfProjectRemoved(project, fileName);

                        var projectDir = Path.GetDirectoryName(project.FullName);

                        AssertDocumentEvents(projectDir,
                            OnQueryRemoveFiles(fileName),
                            OnAfterRemoveFiles(fileName)
                        );
                    }
                }
            }
        }
Example #20
0
        public void IncludeInProject() {
            using (var app = new VisualStudioApp()) {
                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                foreach (var projectType in ProjectTypes) {
                    var testDef = SourceControlProject(projectType);

                    using (var solution = testDef.Generate().ToVs()) {
                        TestSccProvider.DocumentEvents.Clear();
                        var project = app.OpenProject(solution.SolutionFilename, onDialog: OnNoSccDialog);
                        var window = app.SolutionExplorerTreeView;
                        var fileName = projectType.Code(@"ExcludedFile");

                        // Try to select the file.  If it throws, it is likely the issue was that we weren't showing all files.
                        try {
                            window.WaitForChildOfProject(project, fileName).Select();
                        } catch (Exception) {
                            // Show all files so we can see the excluded item if we previously couldn't
                            solution.ExecuteCommand("Project.ShowAllFiles");
                            window.WaitForChildOfProject(project, fileName).Select();
                        }

                        solution.ExecuteCommand("Project.IncludeInProject");

                        System.Threading.Thread.Sleep(250);

                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                            OnQueryAddFiles(fileName),
                            OnAfterAddFilesEx(fileName)
                        );
                    }
                }
            }
        }
Example #21
0
        public void AddExistingItem() {
            using (var app = new VisualStudioApp()) {

                // close any projects before switching source control...
                app.Dte.Solution.Close();

                app.SelectSourceControlProvider("Test Source Provider");
                foreach (var projectType in ProjectTypes) {
                    var testDef = SourceControlProject(projectType);

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

                        var project = app.OpenProject(solution.Filename, onDialog: OnNoSccDialog);
                        var fileName = projectType.Code(@"ExcludedFile");

                        using (var newItem = AddExistingItemDialog.FromDte(app)) {
                            newItem.FileName = fileName;
                            newItem.OK();
                        }

                        System.Threading.Thread.Sleep(250);

                        Assert.IsNotNull(project.ProjectItems.Item(fileName));
                        AssertDocumentEvents(Path.GetDirectoryName(project.FullName),
                            OnQueryAddFiles(fileName),
                            OnAfterAddFilesEx(fileName)
                        );
                    }
                }
            }
        }