public void HierarchyIsCorrectlyFormed() { string[] configurations = { "Debug" }; string[] platforms = { "AnyCPU" }; List <SlnProject> projects = new List <SlnProject> { new SlnProject(@"D:\zoo\foo\bar\baz\baz.csproj", "baz", Guid.NewGuid(), SlnProject.DefaultLegacyProjectTypeGuid, configurations, platforms, false, isDeployable: false), new SlnProject(@"D:\zoo\foo\bar\baz1\baz1.csproj", "baz1", Guid.NewGuid(), SlnProject.DefaultLegacyProjectTypeGuid, configurations, platforms, false, isDeployable: false), new SlnProject(@"D:\zoo\foo\bar\baz2\baz2.csproj", "baz2", Guid.NewGuid(), SlnProject.DefaultLegacyProjectTypeGuid, configurations, platforms, false, isDeployable: false), new SlnProject(@"D:\zoo\foo\bar1\bar1.csproj", "bar1", Guid.NewGuid(), SlnProject.DefaultLegacyProjectTypeGuid, configurations, platforms, false, isDeployable: false), }; SlnHierarchy hierarchy = new SlnHierarchy(projects); hierarchy.Folders.Select(i => i.FullPath) .ShouldBe(new[] { @"D:\zoo\foo\bar\baz", @"D:\zoo\foo\bar\baz1", @"D:\zoo\foo\bar\baz2", @"D:\zoo\foo\bar", @"D:\zoo\foo\bar1", @"D:\zoo\foo", }); foreach (SlnProject project in projects) { hierarchy .Folders .First(i => i.FullPath.Equals(Path.GetDirectoryName(project.FullPath))) .Projects.ShouldHaveSingleItem() .ShouldBe(project); } }
public void HierarchyIgnoresCase() { SlnProject[] projects = new[] { new SlnProject { FullPath = Path.Combine(_driveRoot, "Code", "ProjectA", "ProjectA.csproj"), Name = "ProjectA", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = Path.Combine(_driveRoot, "code", "ProjectB", "ProjectB.csproj"), Name = "ProjectB", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, }; SlnHierarchy hierarchy = SlnHierarchy.CreateFromProjectDirectories(projects); GetFolderStructureAsString(hierarchy.Folders).ShouldBe( $@"{_driveRoot}Code - Code {_driveRoot}Code{Path.DirectorySeparatorChar}ProjectA - ProjectA {_driveRoot}code{Path.DirectorySeparatorChar}ProjectB - ProjectB", StringCompareShould.IgnoreLineEndings); }
public void HierarchyIsCorrectlyFormed() { DummyFolder root = DummyFolder.CreateRoot(@"D:\zoo\foo"); DummyFolder bar = root.AddSubDirectory("bar"); bar.AddProjectWithDirectory("baz"); bar.AddProjectWithDirectory("baz1"); bar.AddProjectWithDirectory("baz2"); root.AddProjectWithDirectory("bar1"); List <SlnProject> projects = root.GetAllProjects(); SlnHierarchy hierarchy = new SlnHierarchy(projects); hierarchy.Folders.Select(i => i.FullPath).OrderBy(s => s) .ShouldBe(root.GetAllFolders().Select(f => f.FullPath).OrderBy(s => s)); foreach (SlnProject project in projects) { hierarchy .Folders .First(i => i.FullPath.Equals(Path.GetDirectoryName(project.FullPath))) .Projects.ShouldHaveSingleItem() .ShouldBe(project); } }
public void HierarchyIgnoresCase() { SlnProject[] projects = new[] { new SlnProject { FullPath = Path.Combine(@"E:\Code", "ProjectA", "ProjectA.csproj"), Name = "ProjectA", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = Path.Combine(@"E:\code", "ProjectB", "ProjectB.csproj"), Name = "ProjectB", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, }; SlnHierarchy hierarchy = SlnHierarchy.CreateFromProjectDirectories(projects); hierarchy.Folders.Select(i => i.FullPath).ShouldBe(new[] { @"E:\Code\ProjectA", @"E:\code\ProjectB", @"E:\Code", }); }
public void HierarchyIsCorrectlyFormed() { List <SlnProject> projects = new List <SlnProject> { new SlnProject { FullPath = @"D:\zoo\foo\bar\baz\baz.csproj", Name = "baz", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = @"D:\zoo\foo\bar\baz1\baz1.csproj", Name = "baz1", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = @"D:\zoo\foo\bar\baz2\baz2.csproj", Name = "baz2", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = @"D:\zoo\foo\bar1\bar1.csproj", Name = "bar1", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, }; SlnHierarchy hierarchy = new SlnHierarchy(projects); hierarchy.Folders.Select(i => i.FullPath) .ShouldBe(new[] { @"D:\zoo\foo\bar\baz", @"D:\zoo\foo\bar\baz1", @"D:\zoo\foo\bar\baz2", @"D:\zoo\foo\bar", @"D:\zoo\foo\bar1", @"D:\zoo\foo", }); foreach (SlnProject project in projects) { hierarchy .Folders .First(i => i.FullPath.Equals(Path.GetDirectoryName(project.FullPath))) .Projects.ShouldHaveSingleItem() .ShouldBe(project); } }
public void HierarchyWithCollapsedFoldersIsCorrectlyFormed() { DummyFolder root = DummyFolder.CreateRoot(@"D:\zoo\foo"); DummyFolder bar = root.AddSubDirectory("bar"); DummyFolder qux = bar.AddSubDirectory("qux"); SlnProject baz = qux.AddProjectWithDirectory("baz"); SlnProject baz1 = qux.AddProjectWithDirectory("baz1"); SlnProject baz2 = qux.AddProjectWithDirectory("baz2"); SlnProject bar1 = root.AddProjectWithDirectory("bar1"); SlnProject baz3 = root .AddSubDirectory("foo1") .AddSubDirectory("foo2") .AddProjectWithDirectory("baz3"); DummyFolder rootExpected = DummyFolder.CreateRoot(@"D:\zoo\foo"); DummyFolder barQuxExpected = rootExpected.AddSubDirectory($"bar {SlnHierarchy.Separator} qux"); barQuxExpected.Projects.Add(baz); barQuxExpected.Projects.Add(baz1); barQuxExpected.Projects.Add(baz2); rootExpected.Projects.Add(bar1); rootExpected.AddSubDirectory($"foo1 {SlnHierarchy.Separator} foo2 {SlnHierarchy.Separator} baz3").Projects.Add(baz3); SlnHierarchy hierarchy = new SlnHierarchy(root.GetAllProjects(), collapseFolders: true); SlnFolder[] resultFolders = hierarchy.Folders.OrderBy(f => f.FullPath).ToArray(); DummyFolder[] expectedFolders = rootExpected.GetAllFolders().OrderBy(f => f.FullPath).ToArray(); resultFolders.Length.ShouldBe(expectedFolders.Length); for (int i = 0; i < resultFolders.Length; i++) { SlnFolder resultFolder = resultFolders[i]; DummyFolder expectedFolder = expectedFolders[i]; resultFolder.Name.ShouldBe(expectedFolder.Name); // Verify that expected and results projects match resultFolder.Projects.Count.ShouldBe(expectedFolder.Projects.Count); resultFolder.Projects.ShouldAllBe(p => expectedFolder.Projects.Contains(p)); // Verify that expected and results child folders match resultFolder.Folders.Count.ShouldBe(expectedFolder.Folders.Count); resultFolder.Folders.ShouldAllBe(p => expectedFolder.Folders.Exists(f => f.Name == p.Name)); } }
public void HierarchyIsCorrectlyFormed() { SlnProject[] projects = { new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "zoo", "foo", "bar", "baz", "baz")}.csproj", Name = "baz", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "zoo", "foo", "bar", "baz1", "baz1")}.csproj", Name = "baz1", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "zoo", "foo", "bar", "baz2", "baz2")}.csproj", Name = "baz2", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "zoo", "foo", "bar1", "bar1")}.csproj", Name = "bar1", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, }; SlnHierarchy hierarchy = SlnHierarchy.CreateFromProjectDirectories(projects); GetFolderStructureAsString(hierarchy.Folders).ShouldBe( $@"{_driveRoot}zoo{Path.DirectorySeparatorChar}foo - foo {_driveRoot}zoo{Path.DirectorySeparatorChar}foo{Path.DirectorySeparatorChar}bar - bar {_driveRoot}zoo{Path.DirectorySeparatorChar}foo{Path.DirectorySeparatorChar}bar{Path.DirectorySeparatorChar}baz - baz {_driveRoot}zoo{Path.DirectorySeparatorChar}foo{Path.DirectorySeparatorChar}bar{Path.DirectorySeparatorChar}baz1 - baz1 {_driveRoot}zoo{Path.DirectorySeparatorChar}foo{Path.DirectorySeparatorChar}bar{Path.DirectorySeparatorChar}baz2 - baz2 {_driveRoot}zoo{Path.DirectorySeparatorChar}foo{Path.DirectorySeparatorChar}bar1 - bar1", StringCompareShould.IgnoreLineEndings); }
public void SingleFolderWithProjectsShouldNotCollapseIntoParentFolderWithProjects() { SlnProject[] projects = { new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "src", "subfolder", "project1", "project1")}.csproj", Name = "project1", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "src", "subfolder", "project1Tests", "project1Tests")}.csproj", Name = "project1Tests", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "src", "project2", "project2")}.csproj", Name = "project2", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "project3", "project3")}.csproj", Name = "project3", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, }; SlnHierarchy hierarchy = SlnHierarchy.CreateFromProjectDirectories(projects, collapseFolders: true); GetFolderStructureAsString(hierarchy.Folders).ShouldBe( $@"{_driveRoot}foo - foo {_driveRoot}foo{Path.DirectorySeparatorChar}src - src {_driveRoot}foo{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}subfolder - subfolder", StringCompareShould.IgnoreLineEndings); }
public void HierarchyWithMultipleSubfoldersUnderACollapsedFolderIsCorrectlyFormed() { SlnProject[] projects = { new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "src", "subfolder", "src", "project1", "project1")}.csproj", Name = "project1", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "src", "subfolder", "tests", "project1Tests", "project1Tests")}.csproj", Name = "project1Tests", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, new SlnProject { FullPath = $"{Path.Combine(_driveRoot, "foo", "project2", "project2")}.csproj", Name = "project2", ProjectGuid = Guid.NewGuid(), ProjectTypeGuid = SlnProject.DefaultLegacyProjectTypeGuid, }, }; SlnHierarchy hierarchy = SlnHierarchy.CreateFromProjectDirectories(projects, collapseFolders: true); GetFolderStructureAsString(hierarchy.Folders).ShouldBe( $@"{_driveRoot}foo - foo {_driveRoot}foo{Path.DirectorySeparatorChar}src - src {SlnHierarchy.Separator} subfolder {_driveRoot}foo{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}subfolder{Path.DirectorySeparatorChar}src - src {_driveRoot}foo{Path.DirectorySeparatorChar}src{Path.DirectorySeparatorChar}subfolder{Path.DirectorySeparatorChar}tests - tests", StringCompareShould.IgnoreLineEndings); }