public void TestNodeProperties() { 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 = TestUtils.GetNewFileName(project.ProjectFolder, "test", "cs"); ProjectElement item = project.CreateMsBuildFileItem(newFileName, "Content"); FileNode node = project.CreateFileNode(item); FileNodeProperties props = node.NodeProperties as FileNodeProperties; Assert.IsNotNull(props); // Test the build action. Assert.IsTrue(props.BuildAction == BuildAction.Content, "The BuildAction build action should be set to compile model"); props.BuildAction = BuildAction.Compile; Assert.IsTrue(props.BuildAction == BuildAction.Compile, "BuildAction has not been set correctly in the project file"); props.BuildAction = BuildAction.EmbeddedResource; Assert.IsTrue(props.BuildAction == BuildAction.EmbeddedResource, "BuildAction has not been set correctly in the project file"); props.BuildAction = BuildAction.None; Assert.IsTrue(props.BuildAction == BuildAction.None, "BuildAction has not been set correctly in the project file"); }); }
private static void AddNonMemberFileItems(ProjectNode project, IEnumerable <string> fileList) { ErrorHelper.ThrowIsNull(fileList, "fileList"); foreach (string fileKey in fileList) { HierarchyNode parentNode = project; string[] pathItems = fileKey.Split(new[] { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar }); if (StringComparer.OrdinalIgnoreCase.Equals(fileKey, project.ProjectFile)) { continue; } NemerleFolderNode topFolderNode = null; foreach (string fileOrDir in pathItems) { string childNodeId = Path.Combine(parentNode.VirtualNodeName, fileOrDir); FileInfo fileOrDirInfo = new FileInfo(Path.Combine(project.ProjectFolder, childNodeId)); if ((fileOrDirInfo.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) { break; } HierarchyNode childNode = parentNode.FindChild(childNodeId); if (childNode == null) { if (topFolderNode == null) { topFolderNode = parentNode as NemerleFolderNode; if (topFolderNode != null && (!topFolderNode.IsNonMemberItem) && topFolderNode.IsExpanded) { topFolderNode = null; } } ProjectElement element = new ProjectElement(project, null, true); element.Rename(childNodeId); element.SetMetadata(ProjectFileConstants.Name, childNodeId); childNode = project.CreateFileNode(element); parentNode.AddChild(childNode); break; } parentNode = childNode; } if (topFolderNode != null) { topFolderNode.CollapseFolder(); } } }
public void TestCreatingFileNode() { 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 = TestUtils.GetNewFileName(project.ProjectFolder, "test", "cs"); ProjectElement item = project.CreateMsBuildFileItem(newFileName, "Compile"); FileNode node = project.CreateFileNode(item); Assert.IsNotNull(node); }); }
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)); }); }