public AddNewItemFromVsTemplate ( ProjectItems parent, string templateName, string language, string name ) : ProjectItem | ||
parent | ProjectItems | the parent collection for the new item |
templateName | string | |
language | string | |
name | string | |
return | ProjectItem |
public void VBWinformsApplication() { 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"; var dte = (DTE) VsIdeTestHostContext.ServiceProvider.GetService( typeof (DTE) ); var testUtils = new TestUtils(); testUtils.CreateEmptySolution( TestContext.TestDir, solutionName ); Assert.AreEqual( 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( 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" ); } ); }