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));
		}
		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 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 TestHasChildrenChanges()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			HierarchyNode slnNode = new HierarchyNode(solution);
			Assert.IsFalse(slnNode.HasChildren);
			string docName = "Doc1.doc";
			hierarchy.AddChild(docName);
			Assert.IsTrue(slnNode.HasChildren);
		}
		public void ShouldReturnTypeGuidForSolutionFile()
		{
			MockVSHierarchy root = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(root);
			string childName = "Child1.txt";
			root.AddChild(childName);

			HierarchyNode slnNode = new HierarchyNode(solution);
			HierarchyNode childNode = slnNode.FindByName(childName);

			Assert.AreEqual<Guid>(VSConstants.GUID_ItemType_PhysicalFile, childNode.TypeGuid);
		}
		public void TestFileHasIcon()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			string docName = "Doc1.doc";
			hierarchy.AddChild(docName);
			HierarchyNode slnNode = new HierarchyNode(solution);
			HierarchyNode node = slnNode.FindByName(docName);
			Assert.IsNotNull(node.Icon);
		}
		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));
		}
		public void FindByName()
		{
			MockVSHierarchy hierarchy = new MockVSHierarchy();
			MockVsSolution solution = new MockVsSolution(hierarchy);
			string child1 = "Child1";
			string child2 = "Child2";
			string child3 = "Child3";
			string child4 = "Child4";
			hierarchy.AddChild(child1);
			hierarchy.AddChild(child2);
			hierarchy.AddChild(child3);
			HierarchyNode node = new HierarchyNode(solution);
			Assert.IsNotNull(node.FindByName(child1));
			Assert.IsNotNull(node.FindByName(child2));
			Assert.IsNotNull(node.FindByName(child3));
			Assert.IsNull(node.FindByName(child4));
		}