Exemple #1
0
        public void WinformsApplication()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                TestUtils testUtils = new TestUtils();

                testUtils.CreateEmptySolution(TestContext.TestDir, "CSWinApp");
                Assert.AreEqual <int>(0, testUtils.ProjectCount());

                //Create Winforms application project
                //TestUtils.CreateProjectFromTemplate("MyWindowsApp", "Windows Application", "CSharp", false);
                //Assert.AreEqual<int>(1, TestUtils.ProjectCount());

                //TODO Verify that we can debug launch the application

                //TODO Set Break point and verify that will hit

                //TODO Verify Adding new project item to project
            });
        }
        public void WhenShieldedActionThrows_ThenExceptionIsLogged()
        {
            var traceSource = new Mock <ITracer>();

            using (new DialogBoxPurger(0))
            {
                UIThreadInvoker.Invoke((Action)(() =>
                {
                    TraceSourceExtensions.ShieldUI(
                        traceSource.Object,
                        () => { throw new ArgumentException("Foo"); },
                        "Bar");
                }));
            }

            traceSource.Verify(x => x.Trace(TraceEventType.Error,
                                            It.Is <ArgumentException>(ex => ex.Message == "Foo"),
                                            "Bar"),
                               Times.Once());
        }
        public void WhenCreatingAProduct_ThenSetsArtifactLinks()
        {
            IProduct product = null;

            UIThreadInvoker.Invoke((Action)(() =>
            {
                DoActionWithWait(4000, () => product = this.manager.CreateProduct(toolkit, "Foo"));
            }));

            Assert.NotNull(product);
            Assert.NotNull(product.TryGetReference(ReferenceKindConstants.SolutionItem));

            Assert.True(product.Views.Count() > 0);
            var view = product.Views.ElementAt(0);

            Assert.True(view.Elements.Count() > 0);
            var element = view.Elements.ElementAt(0);

            Assert.NotNull(element.TryGetReference(ReferenceKindConstants.SolutionItem));
        }
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate() {
                var menuItemCmd = new CommandID(GuidList.guidShowMyGitBranchCmdSet, (int)PkgCmdIDList.cmdidFirstCommand);

                // Create the DialogBoxListener Thread.
                var expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "ShowMyGitBranch", "ThiagoSa.ShowMyGitBranch.ShowMyGitBranchPackage");
                var purger = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try {
                    purger.Start();

                    var testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #5
0
        //[HostType("VS IDE")]
        public void PackageLoadTest()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the Shell Service
                IVsShell shellService = VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsShell)) as IVsShell;
                Assert.IsNotNull(shellService);

                //Validate package load
                IVsPackage package;
                Guid packageGuid = AnkhId.PackageGuid;
                Assert.IsTrue(0 == shellService.LoadPackage(ref packageGuid, out package));
                Assert.IsNotNull(package, "Package failed to load");


                packageGuid = AnkhId.WpfPackageGuid;
                Assert.IsTrue(0 == shellService.LoadPackage(ref packageGuid, out package));
                Assert.IsNotNull(package, "Package failed to load");
            });
        }
Exemple #6
0
        /// <summary>
        /// Executes the specified command on the specified project item twice and verifies the
        /// second execution does not result in any changes.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="projectItem">The project item to execute the command upon.</param>
        public static void ExecuteCommandTwiceAndVerifyNoChangesOnSecondPass(Action <Document> command, ProjectItem projectItem)
        {
            UIThreadInvoker.Invoke(new Action(() =>
            {
                var document = GetActivatedDocument(projectItem);

                // Run command a first time and assert it is not saved afterwards.
                Assert.IsTrue(document.Saved);
                command(document);
                Assert.IsFalse(document.Saved);

                // Save the document.
                document.Save();
                Assert.IsTrue(document.Saved);

                // Run command a second time and assert it is still in a saved state (i.e. no changes).
                command(document);
                Assert.IsTrue(document.Saved);
            }));
        }
Exemple #7
0
        public void InsideSameFolder()
        {
            //"Program3.fs"
            //"Folder1\\File3.fs"
            //"Folder1\\File4.fs"
            //"Folder1\\Sub1\File2.fs"
            //"Folder1\\Sub1\\SubSub1\\File1.fs"
            //"Folder1\\Sub2\\File1.fs"
            //"Folder1\\File1.fs"
            //"Folder2\\File1.fs"
            //"Program.fs"
            //"Program2.fs"
            //"Folder3\\CompileFile1.fs",
            //"Folder3\\ContentFile1.fs",
            //"Folder3\\NoneFile1.fs"

            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //"It'd be more optimal if root level files won't be swapped in this tests.
                //But they are swapped (manual check,not yet automized)
                new UseCase("InsideSameFolder", testContext)
                .Apply(new Action(1, Move.Down))
                .Apply(new Action(3, Move.Down))
                .ExpectedOrder(
                    "Program3.fs",
                    "Folder1\\File4.fs",
                    "Folder1\\File3.fs",
                    "Folder1\\Sub1\\SubSub1\\File1.fs",
                    "Folder1\\Sub1\\File2.fs",
                    "Folder1\\Sub2\\File1.fs",
                    "Folder1\\File1.fs",
                    "Folder2\\File1.fs",
                    "Program.fs",
                    "Program2.fs",
                    "Folder3\\CompileFile1.fs"    //,
                    //"Folder3\\ContentFile1.fs",
                    //"Folder3\\NoneFile1.fs"
                    )
                .Run();
            });
        }
Exemple #8
0
 public void NoneFilesOrder()
 {
     //[0]"Program3.fs",
     //[1]"Folder1\\File3.fs",
     //[2]"Folder1\\File4.fs",
     //[3]"Folder1\\Sub1\File2.fs",
     //[4]"Folder1\\Sub1\\SubSub1\\File1.fs",
     //[5]"Folder1\\Sub2\\File1.fs",
     //[6]"Folder1\\File1.fs",
     //[7]"Folder2\\File1.fs",
     //[8]"Program.fs",
     //[9]"Program2.fs",
     //[10]"Folder3\\CompileFile1.fs",
     //[11]"Folder3\\ContentFile1.fs",
     //[12]"Folder3\\NoneFile1.fs"
     UIThreadInvoker.Invoke((ThreadInvoker) delegate()
     {
         new UseCase("NoneFilesOrder", testContext)
         .Apply(new Action(10, Move.Up))
         .Apply(new Action(9, Move.Up))
         .Apply(new Action(8, Move.Up))
         .Apply(new Action(7, Move.Up))
         .Apply(new Action(6, Move.Up))
         .ExpectedOrder(
             "Program3.fs",
             "Folder1\\File3.fs",
             "Folder1\\File4.fs",
             "Folder1\\Sub1\\File2.fs",
             "Folder1\\Sub1\\SubSub1\\File1.fs",
             "Folder3\\CompileFile1.fs",
             "Folder1\\Sub2\\File1.fs",
             //"Folder3\\ContentFile1.fs",
             //"Folder3\\NoneFile1.fs"
             "Folder1\\File1.fs",
             "Folder2\\File1.fs",
             "Program.fs",
             "Program2.fs"    //,
             )
         .Run();
     });
 }
Exemple #9
0
        public void BetweenDiffFolders1()
        {
            //"Program3.fs"
            //"Folder1\\File3.fs"
            //"Folder1\\File4.fs"
            //"Folder1\\Sub1\File2.fs"
            //"Folder1\\Sub1\\SubSub1\\File1.fs"
            //"Folder1\\Sub2\\File1.fs"
            //"Folder1\\File1.fs"
            //"Folder2\\File1.fs"
            //"Program.fs"
            //"Program2.fs"
            //"Folder3\\CompileFile1.fs",
            //"Folder3\\ContentFile1.fs",
            //"Folder3\\NoneFile1.fs"


            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                new UseCase("BetweenDiffFolders", testContext)
                .Apply(new Action(3, Move.Up))
                .Apply(new Action(2, Move.Up))
                .Apply(new Action(1, Move.Up))
                .ExpectedOrder(
                    "Folder1\\Sub1\\File2.fs",
                    "Program3.fs",
                    "Folder1\\File3.fs",
                    "Folder1\\File4.fs",
                    "Folder1\\Sub1\\SubSub1\\File1.fs",
                    "Folder1\\Sub2\\File1.fs",
                    "Folder1\\File1.fs",
                    "Folder2\\File1.fs",
                    "Program.fs",
                    "Program2.fs",
                    "Folder3\\CompileFile1.fs"    //,
                    //"Folder3\\ContentFile1.fs",
                    //"Folder3\\NoneFile1.fs"
                    )
                .Run();
            });
        }
Exemple #10
0
        public void TestUnloadReloadOfProject()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                Utilities.SelectOrUnselectNodes <ProjectNode>(project, true);

                // Save everything.
                IVsSolution solutionService = (IVsSolution)sp.GetService(typeof(IVsSolution));
                solutionService.SaveSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_SaveIfDirty, project, 0);

                string projectFullpath = project.GetMkDocument();
                object customin        = null;
                object customout       = null;
                dte.Commands.Raise(VsMenus.guidStandardCommandSet97.ToString("B"), (int)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.UnloadProject, ref customin, ref customout);
                // Check to see if the project is unloaded
                Assert.IsTrue(project.IsClosed, "The project has not been unloaded");

                dte.Commands.Raise(VsMenus.guidStandardCommandSet97.ToString("B"), (int)Microsoft.VisualStudio.VSConstants.VSStd97CmdID.ReloadProject, ref customin, ref customout);

                // Check to see if the project is reloaded. we cannot use the instance for the project since that is zombied at this point.
                IVsHierarchy ourHierarchy;
                solutionService.GetProjectOfUniqueName(projectFullpath, out ourHierarchy);
                Assert.IsTrue(ourHierarchy is IProjectEventsListener, "Our hierarchy has not been reloaded successfully");

                // Check to see if the nested project is there.
                EnvDTE.Project projectDTE = Utilities.GetAutomationObject(ourHierarchy);
                Assert.IsNotNull(projectDTE.ProjectItems.Item("ANestedProject"), "The nested project has not been loaded correctly.");

                // Check that bug 106520 does not happen anymore. We will check that the parent project is not dirty.
                int isDirty;
                ((IPersistFileFormat)ourHierarchy).IsDirty(out isDirty);
                Assert.IsTrue(isDirty == 0, "The parent project is dirtied after it has been reloaded");
            });
        }
Exemple #11
0
        public void TestSaveAsInNewDirectory()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                //Create a project and get the first filenode
                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                FileNode fileNode = GetFirstFileNode(project);

                //open the item before we can do the SaveAs op
                ProjectItem item = ((OAFileItem)fileNode.GetAutomationObject());
                Window window    = item.Open(EnvDTE.Constants.vsViewKindPrimary);
                Assert.IsNotNull(window, "Did not get a reference to the window for the file just opened");
                if (!window.Visible)
                {
                    window.Visible = true;
                }

                //Create new directory
                string newDirectoryName = "NewDirectory1";
                string pathToDir        = Path.Combine(project.ProjectFolder, newDirectoryName);
                DirectoryInfo dirInfo   = Directory.CreateDirectory(pathToDir);

                //SaveAs
                string newNameOfFile   = "Test.cs";
                string relPathToFile   = newDirectoryName + "\\" + "Test.cs";
                string updatedFileName = Path.Combine(project.ProjectFolder, relPathToFile);
                item.SaveAs(updatedFileName);

                //Verify Caption in window of the file renamed
                Assert.IsTrue(string.Compare(window.Caption, newNameOfFile, true) == 0, "Caption of window does not match the new filename");

                //Verify full path to document
                Assert.IsTrue(string.Compare(window.Document.FullName, updatedFileName, true) == 0, "FullName of document is not as expected");
            });
        }
        public void VBWinformsApplicationReload()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Solution and project creation parameters
                string solutionName = "VBWinApp";
                string projectName  = "VBWinApp";

                //Template parameters
                string language            = "VisualBasic";
                string projectTemplateName = "WindowsApplication.Zip";
                string itemTemplateName    = "CodeFile.zip";
                string newFileName         = "Test.vb";

                DTE dte = (DTE)VsIdeTestHostContext.ServiceProvider.GetService(typeof(DTE));

                TestUtils testUtils = new TestUtils();

                string testDir = char.ToLower(TestContext.TestDir[0]) + TestContext.TestDir.Substring(1);

                testUtils.CreateEmptySolution(testDir, solutionName);
                Assert.AreEqual <int>(0, testUtils.ProjectCount());

                //Add new  Windows application project to existing solution
                testUtils.CreateProjectFromTemplate(projectName, projectTemplateName, language, false);

                //Verify that the new project has been added to the solution
                Assert.AreEqual <int>(1, testUtils.ProjectCount());

                //Get the project
                Project project = dte.Solution.Item(1);
                Assert.IsNotNull(project);
                Assert.IsTrue(string.Compare(project.Name, projectName, StringComparison.InvariantCultureIgnoreCase) == 0);

                //Verify Adding new code file to project
                ProjectItem newCodeFileItem = testUtils.AddNewItemFromVsTemplate(project.ProjectItems, itemTemplateName, language, newFileName);
                Assert.IsNotNull(newCodeFileItem, "Could not create new project item");

                ReloadProject(0);
            });
        }
Exemple #13
0
        public void TestLoadingOfProjectWithDuplicateItems()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                string path = project.GetMkDocument();

                // It would be nice if we could just copy the embedded resource to the opened project file, but implicit reload of nested projects crashes on non SP1 versions.
                // For now we are going to close the project and reopen it with the embedded project.
                IVsSolution solutionService = (IVsSolution)sp.GetService(typeof(IVsSolution));

                solutionService.CloseSolutionElement((uint)__VSSLNSAVEOPTIONS.SLNSAVEOPT_ForceSave, project, 0);

                TestUtils.WriteEmbeddedResourceToBinaryFile(typeof(TestProject).Assembly, EmbeddedResourceProjectLocation, path);

                IntPtr projectPtr = IntPtr.Zero;
                Guid guid         = Guid.Empty;
                Guid iid          = new Guid("{00000000-0000-0000-C000-000000000046}");        // IID_IUnknown;

                try
                {
                    ErrorHandler.ThrowOnFailure(solutionService.CreateProject(ref guid, path, null, null, (uint)__VSCREATEPROJFLAGS.CPF_OPENFILE, ref iid, out projectPtr));

                    // Now see that we have only unique items. We do not care much about canonicalization issues in this test.
                    this.CheckForUniqueCaptions(project);
                }
                finally
                {
                    if (projectPtr != IntPtr.Zero)
                    {
                        Marshal.Release(projectPtr);
                    }
                }
            });
        }
Exemple #14
0
		//[TestCategory("IntegrationTest"), TestMethod]
		//[HostType("VS IDE")]
		public void TestSourcetrailExtensionPackageGetsLoaded()
		{
			UIThreadInvoker.Initialize();
			UIThreadInvoker.Invoke(new Action(() =>
			{
				// Load the package into the shell.
				Assert.IsNotNull(VsIdeTestHostContext.ServiceProvider);
				IVsShell shellService = (IVsShell)VsIdeTestHostContext.ServiceProvider.GetService(typeof(SVsShell));
				Guid packageGuid = new Guid(GuidList.guidSourcetrailExtensionPkgString);

				IVsPackage package;
				shellService.IsPackageLoaded(ref packageGuid, out package);
				if (package == null)
				{
					shellService.LoadPackage(ref packageGuid, out package);
				}

				Assert.IsNotNull(package);
				Assert.IsTrue(package is SourcetrailExtensionPackage);
			}));
		}
Exemple #15
0
        public void TestAddChild()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                string newFileName = "output.txt";

                FileNode node = project.CreateFileNode(newFileName);
                Assert.IsNotNull(node);

                project.AddChild(node);

                Assert.IsTrue(node == project.FindChildByProjectElement(node.ItemNode));
            });
        }
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                var menuItemCmd = new CommandID(FSharpVSPowerTools.Constants.guidStandardCmdSet,
                                                (int)FSharpVSPowerTools.Constants.cmdidStandardRenameCommand);
                // Create the DialogBoxListener Thread.
                var expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "PowerToolsCommandsPackage", "FSharpVSPowerTools.PowerToolsCommandsPackage");
                var purger = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();
                    TestUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #17
0
        public void TestDangereousTargets()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string mainProjFilename = CreateTempFileOnDisk(@"
			                
								<Project DefaultTargets=`Build`  xmlns=`msbuildnamespace`>
								  <Import Project=`$(MSBuildBinPath)\Microsoft.CSharp.targets`/>
								  <Target
										Name=`PrepareForBuild`>
										<PropertyGroup>
											<TargetDir>$(TargetDir)</TargetDir>
											<TargetPath>$(TargetPath)</TargetPath>
										</PropertyGroup>
								 </Target>                       
							   </Project>

							"                            );

                try
                {
                    ProjectSecurityChecker projectSecurityChecker = new ProjectSecurityChecker(sp, mainProjFilename);
                    MethodInfo mi    = projectSecurityChecker.GetType().GetMethod("IsProjectSafeWithTargets", BindingFlags.Instance | BindingFlags.NonPublic);
                    string[] message = new string[1] {
                        String.Empty
                    };
                    bool result = (bool)mi.Invoke(projectSecurityChecker, message);

                    Assert.IsTrue(!result && !String.IsNullOrEmpty(message[0]), "No message returned from a project with redefined safe targets.");
                }
                finally
                {
                    File.Delete(mainProjFilename);
                }
            });
        }
Exemple #18
0
        public void TestDangereousUsingTasks()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string mainProjFilename = CreateTempFileOnDisk(@"                
			                   
								<Project xmlns=`msbuildnamespace`>

									<UsingTask 
										TaskName=`Microsoft.Build.Tasks.FormatUrl` 
										AssemblyName=`Microsoft.Build.Tasks, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a`/>

									<UsingTask 
										TaskName=`Microsoft.Build.Tasks.FormatVersion` 
										AssemblyName=`Microsoft.Build.Tasks, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a`/>
									<Import Project=`$(MSBuildBinPath)\Microsoft.CSharp.targets`/> 
								</Project>
							"                            );

                try
                {
                    ProjectSecurityChecker projectSecurityChecker = new ProjectSecurityChecker(sp, mainProjFilename);
                    MethodInfo mi    = projectSecurityChecker.GetType().GetMethod("IsProjectSafeWithUsingTasks", BindingFlags.Instance | BindingFlags.NonPublic);
                    string[] message = new string[1] {
                        String.Empty
                    };
                    bool result = (bool)mi.Invoke(projectSecurityChecker, message);

                    Assert.IsTrue(!result && !String.IsNullOrEmpty(message[0]), "No message returned from a project with not safe taks.");
                }
                finally
                {
                    File.Delete(mainProjFilename);
                }
            });
        }
Exemple #19
0
        public void TestAutomationOnProject()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination = Path.Combine(TestContext.TestDir, TestContext.TestName);
                Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                EnvDTE.Project automation = Utilities.FindExtObject(sp, Utilities.NestedProjectGuid, TestContext.TestName);

                // Test save and Save As
                #region Save with bad input
                this.BadFileNameChecks(automation, true);
                string badFileName = "AnotherFileNotThesameAsTheProjectFile.nestedProj";
                Assert.IsTrue(this.CheckForSaveWithBadFileName <InvalidOperationException>(automation, true, badFileName, String.Empty), "The file named " + badFileName + " could be saved");
                #endregion

                ProjectNode project = ((OANestedProject)automation).Project;
                automation.Save(project.Url);
                int isDirty;
                project.IsDirty(out isDirty);
                Assert.IsTrue(isDirty == 0, "The project was not saved correctly from automation");

                #region save as bad input
                this.BadFileNameChecks(automation, false);
                badFileName = @"..\..\";
                Assert.IsTrue(this.CheckForSaveWithBadFileName <InvalidOperationException>(automation, true, badFileName, String.Empty), "The file named " + badFileName + " could be saved");
                #endregion

                string goodFileName = "ANewProjectFile.nestedproj";
                automation.SaveAs(goodFileName);
                Assert.IsTrue((String.Compare(project.ProjectFile, goodFileName, StringComparison.OrdinalIgnoreCase) == 0), "Save as failed since the file comparison test failed");

                this.TestFileNamesThatShouldPassForSaveAs(automation);
            });
        }
Exemple #20
0
        /// <summary>
        /// Executes the specified command on the specified project item and verifies the results
        /// against the specified baseline file.
        /// </summary>
        /// <param name="command">The command to execute.</param>
        /// <param name="projectItem">The project item to execute the command upon.</param>
        /// <param name="baselinePath">The path to the baseline file for results comparison.</param>
        public static void ExecuteCommandAndVerifyResults(Action <Document> command, ProjectItem projectItem, string baselinePath)
        {
            UIThreadInvoker.Invoke(new Action(() =>
            {
                var document = GetActivatedDocument(projectItem);

                // Run command and assert it is not saved afterwards.
                Assert.IsTrue(document.Saved);
                command(document);
                Assert.IsFalse(document.Saved);

                // Save the document.
                document.Save();
                Assert.IsTrue(document.Saved);

                // Read the file contents of the baseline and cleaned content and assert they match.
                var baselineContent = File.ReadAllText(baselinePath);
                var cleanedContent  = File.ReadAllText(document.FullName);

                Assert.AreEqual(baselineContent, cleanedContent);
            }));
        }
Exemple #21
0
        public void TestRenameWithBadFileName()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                FileNode fileNode     = null;
                List <FileNode> nodes = Utilities.GetNodesOfType <FileNode>(project);

                if (nodes.Count > 0)
                {
                    fileNode = nodes[0];
                }

                string errorMessage = Utilities.GetResourceStringFromTheProjectAssembly("ErrorInvalidFileName");

                foreach (string newBadFileName in Utilities.BadFileNames)
                {
                    Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, newBadFileName, errorMessage), "The file named " + newBadFileName + " could be saved as");
                }

                string badFileName = "  ";
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

                badFileName = "..\\" + fileNode.FileName;
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

                badFileName = "....";
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, badFileName, errorMessage), "The file named " + badFileName + " could be saved as");

                errorMessage = String.Format(System.Globalization.CultureInfo.CurrentCulture, Utilities.GetResourceStringFromTheProjectAssembly("PathTooLong"), Utilities.LongFileName);
                Assert.IsTrue(Utilities.CheckForSetEditLabelBadFileName <InvalidOperationException>(fileNode, Utilities.LongFileName, errorMessage), "The file named " + Utilities.LongFileName + " could be saved");
            });
        }
Exemple #22
0
        [TestMethod, Ignore] // show Dialog
        //[HostType("VS IDE")]
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(AnkhId.CommandSetGuid, (int)AnkhCommand.Checkout);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "AnkhSvn", "AnkhSvn.AnkhSvn.AnkhSvnPackage");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDCANCEL, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #23
0
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(ZinkoSoft.NuSet.GuidList.NuSetCommandGuid, (int)ZinkoSoft.NuSet.PkgCmdIDList.nusetCommand);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "NuSet", "ZinkoSoft.NuSet.NuSetPackage");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(appMobi.AppMobiCloudServiceExtension.GuidList.guidAppMobiCloudServiceExtensionCmdSet, (int)appMobi.AppMobiCloudServiceExtension.PkgCmdIDList.cmdidAppMobiCloudServiceCommand);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "AppMobiCloudServiceExtension", "appMobi.AppMobiCloudServiceExtension.AppMobiCloudServiceExtensionPackage");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #25
0
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(F1SYS.VsGitToolsPackage.GuidList.guidVsGitToolsPackageCmdSet, (int)F1SYS.VsGitToolsPackage.PkgCmdIDList.icmdSccCommandGitBash);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "Git Tools", "F1SYS.VsGitToolsPackage.VsGitToolsPackagePackage");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #26
0
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker)delegate()
            {
                CommandID menuItemCmd = new CommandID(Aljeida.VisualStudio.YUML.GuidList.guidAljeida_VisualStudio_YUMLCmdSet, (int)Aljeida.VisualStudio.YUML.PkgCmdIDList.cmdidViewClassDiagramByYUML);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "YUML", "Aljeida.Aljeida_VisualStudio_YUML.Aljeida_VisualStudio_YUMLPackage");
                DialogBoxPurger purger = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #27
0
        public void TestDesignTimeAssemblyResolution()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                //Get the global service provider and the dte
                IServiceProvider sp = VsIdeTestHostContext.ServiceProvider;
                DTE dte             = (DTE)sp.GetService(typeof(DTE));

                string destination  = Path.Combine(TestContext.TestDir, TestContext.TestName);
                ProjectNode project = Utilities.CreateMyNestedProject(sp, dte, TestContext.TestName, destination, true);

                string[] assemblySpecs = new[] { "System", "System.Core" };
                VsResolvedAssemblyPath[] resolvedPaths = new VsResolvedAssemblyPath[assemblySpecs.Length];
                uint resolvedCount;
                project.GetProjectOptions();                 // force the initial build
                Marshal.ThrowExceptionForHR(project.ResolveAssemblyPathInTargetFx(assemblySpecs, (uint)assemblySpecs.Length, resolvedPaths, out resolvedCount));
                Assert.AreEqual(assemblySpecs.Length, (int)resolvedCount);
                for (int i = 0; i < resolvedCount; i++)
                {
                    Assert.IsTrue(resolvedPaths[i].bstrResolvedAssemblyPath.Contains(resolvedPaths[i].bstrOrigAssemblySpec));
                }
            });
        }
Exemple #28
0
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(SmartPaster2013.GuidList.guidSmartPaster2013CmdSet, (int)SmartPaster2013.PkgCmdIDList.cmdidPasteAsComment);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "SmartPaster2013", "MartinWilley.SmartPaster2013.SmartPaster2013Package");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
Exemple #29
0
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(JosePedroSilva.TFSScrumExtensions.GuidList.guidTFSScrumExtensionsCmdSet, (int)JosePedroSilva.TFSScrumExtensions.PkgCmdIDList.cmdPlanWorkItem);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "TFSScrumExtensions", "JosePedroSilva.TFSScrumExtensions.TFSScrumExtensionsPackage");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }
        public void LaunchCommand()
        {
            UIThreadInvoker.Invoke((ThreadInvoker) delegate()
            {
                CommandID menuItemCmd = new CommandID(MicrosoftCorporation.SlowCheetah.GuidList.guidSlowCheetahCmdSet, (int)MicrosoftCorporation.SlowCheetah.PkgCmdIDList.cmdidAddTransform);

                // Create the DialogBoxListener Thread.
                string expectedDialogBoxText = string.Format(CultureInfo.CurrentCulture, "{0}\n\nInside {1}.MenuItemCallback()", "SlowCheetah", "MicrosoftCorporation.SlowCheetah.SlowCheetahPackage");
                DialogBoxPurger purger       = new DialogBoxPurger(NativeMethods.IDOK, expectedDialogBoxText);

                try
                {
                    purger.Start();

                    TestUtils testUtils = new TestUtils();
                    testUtils.ExecuteCommand(menuItemCmd);
                }
                finally
                {
                    Assert.IsTrue(purger.WaitForDialogThreadToTerminate(), "The dialog box has not shown");
                }
            });
        }