public void CreateVsSolution()
		{
			root = new MockVSHierarchy();
			vsSolution = new MockVsSolution(root);
			project = new MockVSHierarchy("Project.project");
			root.AddProject(project);
		}
        public MockMappingServiceProvider()
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			root.AddProject(new MockVSHierarchy("Project1.project", guid1));
			root.AddProject(new MockVSHierarchy("Project2.project", guid2));
			root.AddProject(new MockVSHierarchy("Project3.project", guid3));
			root.AddProject(new MockVSHierarchy("Project4.project", guid4));
			AddService(typeof(SVsSolution), solution);
			string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"ProjectMapping.xml");
			MockVSHierarchy mappingFileHier = new MockVSHierarchy(filePath, guid5);
			AddService(typeof(IVsRunningDocumentTable), new MockVsRDT(filePath,mappingFileHier,VSConstants.VSITEMID_ROOT));
			AddService(typeof(VsTextManagerClass), new MockVsTextManager());
			AddService(typeof(IVsUIShellOpenDocument), new MockVsUIShellOpenDocument());
			AddService(typeof(ILocalRegistry), new MockLocalRegistry());
			AddService(typeof(IVsFileChangeEx), new MockFileChangeEx());
			AddService(typeof(SVsFileChangeEx), new MockFileChangeEx());
		}
		public void EditValueWithNoFormsServiceThrows()
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockServiceProvider serviceProvider = new MockServiceProvider();
			serviceProvider.AddService(typeof(IVsSolution), solution);
			MockTypeDescriptorContext context = new MockTypeDescriptorContext(serviceProvider);
			string value = "Project1.txt";
			MockVSHierarchy project = new MockVSHierarchy(value);
			root.AddProject(project);
			SolutionPickerEditor target = new SolutionPickerEditor();
			target.EditValue(serviceProvider, null);
		}
		public void ShouldReturnProjectExtension()
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);

			Assert.IsInstanceOfType(project.ExtObject, typeof(EnvDTE.Project));

			TestableArtifactLink artifactLink = new TestableArtifactLink();

			artifactLink.Container = project.GUID;
			artifactLink.ItemName = "TestItem";
			artifactLink.Project = project.ExtObject as EnvDTE.Project;

			Assert.AreEqual<string>(".cs", artifactLink.DefaultExtension);
		}
		public void ShouldFilterOutChildren()
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			string childName = "Child1.txt";
			root.AddChild(childName);
			string projectName = "Project1.project";
			MockVSHierarchy project = new MockVSHierarchy(projectName);
			root.AddProject(project);

			HierarchyNode slnNode = new HierarchyNode(solution);
			HierarchyNode projectNode = new HierarchyNode(solution, project.GUID);
			HierarchyNode childNode = slnNode.FindByName(childName);
			
			OnlyProjectsFilter target = new OnlyProjectsFilter();
			Assert.IsFalse(target.Filter(slnNode));
			Assert.IsTrue(target.Filter(childNode));
			Assert.IsFalse(target.Filter(projectNode));
		}
		private static ProjectNode GetTestProjectNode(string language)
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution vsSolution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project.project");

			MockEnvDTEProject mockEnvDteProject = project.ExtObject as MockEnvDTEProject;
			if (mockEnvDteProject != null)
			{
				mockEnvDteProject.SetCodeModel(new MockCodeModel(language));
			}
			root.AddProject(project);

			ProjectNode projectNode = new ProjectNode(vsSolution, project.GUID);

			return projectNode;
		}
		public void TestValidate()
		{
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);
			serviceProvider.AddService(typeof(SVsSolution), solution);
			CodeGenerationService target = new CodeGenerationService(serviceProvider);
			MyArtifactLink validLink = new MyArtifactLink(project.GUID, "item1.cs");

			Assert.IsTrue(target.IsValid(validLink));
			MyArtifactLink invalidLink1 = new MyArtifactLink(Guid.NewGuid(), "item2.cs");
			Assert.IsFalse(target.IsValid(invalidLink1));
			MyArtifactLink invalidLink2 = new MyArtifactLink(project.GUID, "it:em3.cs");
			Assert.IsFalse(target.IsValid(invalidLink2));
			MyArtifactLink invalidLink3 = new MyArtifactLink(Guid.NewGuid(), "<item3.cs>");
			Assert.IsFalse(target.IsValid(invalidLink3));
		}
		public void TestValidateEmptyRename()
		{
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);
			serviceProvider.AddService(typeof(SVsSolution), solution);
			TestableCodeGenerationService target = new TestableCodeGenerationService(serviceProvider);
			string oldName = "item1";
			string newName = "";
			MyArtifactLink validLink = new MyArtifactLink(project.GUID, oldName + ".cs");
			HierarchyNode node = target.ValidateRename(validLink, newName, oldName);

			Assert.IsNull(node);
			project.AddChild(oldName + ".cs");
			node = target.ValidateRename(validLink, oldName, oldName);
			Assert.IsNull(node);
			Assert.AreEqual<int>(0, target.LogEntries.Count);
			node = target.ValidateRename(validLink, newName, oldName);
			Assert.IsNotNull(node);
			Assert.AreEqual<int>(1, target.LogEntries.Count);
		}
		public void TestArtifactIsGenerated()
		{
			MockServiceProvider serviceProvider = new MockServiceProvider();
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			MockVSHierarchy project = new MockVSHierarchy("Project1.project");
			root.AddProject(project);
			serviceProvider.AddService(typeof(SVsSolution), solution);
			CodeGenerationService target = new CodeGenerationService(serviceProvider);
			MyArtifactLink validLink = new MyArtifactLink(project.GUID, "item1.cs");

			Assert.IsFalse(target.IsArtifactAlreadyGenerated(validLink));
			project.AddChild("item1.cs");
			Assert.IsTrue(target.IsArtifactAlreadyGenerated(validLink));
		}
		public void ShouldReturnTypeGuidForSolutionFolder()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy project = new MockVSHierarchy("Project4.project");
			project.TypeGuid = VSConstants.GUID_ItemType_VirtualFolder;
			hierarchy.AddProject(project);

			HierarchyNode slnNode = new HierarchyNode(solution);
			HierarchyNode prjNode = slnNode.FindByName("Project4.project");

			Assert.AreEqual<Guid>(VSConstants.GUID_ItemType_VirtualFolder, prjNode.TypeGuid);
		}
		public void RemoveItem()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy project = new MockVSHierarchy("Project3.project");
			hierarchy.AddProject(project);
			ProjectNode projectNode = new ProjectNode(solution, project.GUID);
			string itemName = "item1";
			HierarchyNode node = projectNode.AddItem(itemName);
			Assert.IsNotNull(projectNode.FindByName(itemName));
			node.Remove();
			Assert.IsNull(projectNode.FindByName(itemName));
		}
		public void TestRelativePath()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy folder1 = new MockVSHierarchy("folder1");
			hierarchy.AddProject(folder1);
			string child1 = "subFolder1";
			folder1.AddChild(child1);
			HierarchyNode rootNode = new HierarchyNode(solution);
			HierarchyNode folder1Node = rootNode.FindByName("folder1");
			HierarchyNode child1Node = folder1Node.FindByName(child1);
			Assert.IsNotNull(child1Node.RelativePath);
			Assert.AreEqual<string>(Path.Combine(Directory.GetCurrentDirectory(), child1), child1Node.RelativePath);
		}
		public void RecursiveFindByNameIgnoreCase()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy project1 = new MockVSHierarchy("Project1.project");
			hierarchy.AddProject(project1);
			string child1 = "Child1";
			project1.AddChild(child1);
			MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");
			hierarchy.AddProject(project2);
			string child2 = "ChIlD2.cd";
			project2.AddChild(child2);
			string child3 = "ChildThree3";
			project2.AddChild(child3);
			string child4 = "Child4NotAdded";

			HierarchyNode node = new HierarchyNode(solution);
			Assert.IsNull(node.FindByName(child1));
			Assert.IsNull(node.FindByName(child2));
			Assert.IsNull(node.FindByName(child3));
			Assert.IsNull(node.FindByName(child4));
			Assert.IsNotNull(node.RecursiveFindByName(child1.ToLowerInvariant()));
			Assert.IsNotNull(node.RecursiveFindByName(child2.ToUpperInvariant()));
			Assert.IsNotNull(node.RecursiveFindByName(CodeIdentifier.MakeCamel(child3)));
			Assert.IsNull(node.RecursiveFindByName(child4));
		}
		public void RecursiveFindByName()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			MockVSHierarchy project1 = new MockVSHierarchy("Project1.project");
			hierarchy.AddProject(project1);
			string child1 = "Child1";
			project1.AddChild(child1);
			MockVSHierarchy project2 = new MockVSHierarchy("Project2.project");
			hierarchy.AddProject(project2);
			string child2 = "Child2";
			project2.AddChild(child2);
			string child3 = "Child3";
			project2.AddChild(child3);
			string child4 = "Child4";

			HierarchyNode node = new HierarchyNode(solution);
			Assert.IsNull(node.FindByName(child1));
			Assert.IsNull(node.FindByName(child2));
			Assert.IsNull(node.FindByName(child3));
			Assert.IsNull(node.FindByName(child4));
			Assert.IsNotNull(node.RecursiveFindByName(child1));
			Assert.IsNotNull(node.RecursiveFindByName(child2));
			Assert.IsNotNull(node.RecursiveFindByName(child3));
			Assert.IsNull(node.RecursiveFindByName(child4));
		}