public async Task BuildTreeAsync_EmptySnapshot_CreatesRootNode() { // Arrange var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies" }; var snapshot = DependenciesSnapshot.CreateEmpty(ProjectPath); // Act var resultTree = await CreateProvider().BuildTreeAsync(dependenciesRoot, snapshot); // Assert var expectedFlatHierarchy = "Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag="; Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree)); Assert.Equal(s_rootImage.ToProjectSystemType(), resultTree.Icon); Assert.Equal(s_rootImage.ToProjectSystemType(), resultTree.ExpandedIcon); }
public void WhenFindByPathAndNeedToFindDependenciesRoot_ShouldNotFind() { // Arrange var projectFolder = Path.GetDirectoryName(ProjectPath); var provider = CreateProvider(); var projectRoot = new TestProjectTree { Caption = "myproject", Children = { new TestProjectTree { Caption = "MyDependencies", Flags = DependencyTreeFlags.DependenciesRootNodeFlags, Children = { new TestProjectTree { Caption = "level1Child1", FilePath = @"c:\folder\level1Child1" }, new TestProjectTree { Caption = "level1Child2", FilePath = @"c:\folder\level1Child2", Children = { new TestProjectTree { Caption = "level2Child21", FilePath = @"c:\folder\level2Child21" }, new TestProjectTree { Caption = "level1Child22", FilePath = @"c:\folder\level2Child22", Children = { new TestProjectTree { Caption = "level3Child31", FilePath = @"c:\folder\level3Child31" }, new TestProjectTree { Caption = "level3Child32", FilePath = @"level3Child32" } } } } } } } } }; // Act var result = provider.FindByPath(projectRoot, Path.Combine(projectFolder, @"level3Child32")); // Assert Assert.Null(result); }
public async Task WhenOneTargetSnapshotWithExistingDependencies_ShouldApplyChanges() { var dependencyModelRootXxx = new TestDependencyModel { ProviderType = "Xxx", Id = "XxxDependencyRoot", Name = "XxxDependencyRoot", Caption = "XxxDependencyRoot", Resolved = true }; var dependencyModelRootYyy = new TestDependencyModel { ProviderType = "Yyy", Id = "YyyDependencyRoot", Name = "YyyDependencyRoot", Caption = "YyyDependencyRoot" }; var dependencyXxx1 = new TestDependency { ProviderType = "Xxx", Id = "tfm1\\xxx\\dependency1", Name = "dependency1", Path = "dependencyXxxpath", Caption = "Dependency1", SchemaItemType = "Xxx", Resolved = true, TargetFramework = _tfm1 }; var dependencyYyy1 = new TestDependency { ProviderType = "Yyy", Id = "tfm1\\yyy\\dependency1", Name = "dependency1", Path = "dependencyYyypath", Caption = "Dependency1", SchemaItemType = "Yyy", Resolved = true, TargetFramework = _tfm1 }; var dependencyYyyExisting = new TestDependency { ProviderType = "Yyy", Id = "tfm1\\yyy\\dependencyExisting", Name = "dependencyExisting", Path = "dependencyExistingPath", Caption = "DependencyExisting", SchemaItemType = "Yyy", Resolved = true, TargetFramework = _tfm1 }; var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies", Children = { new TestProjectTree { Caption = "OldRootChildToBeRemoved" }, new TestProjectTree { Caption = "YyyDependencyRoot", FilePath = "YyyDependencyRoot", Children = { new TestProjectTree { Caption = "DependencyExisting", FilePath = "tfm1\\yyy\\dependencyExisting" } } } } }; var provider = CreateProvider(rootModels: new[] { dependencyModelRootXxx, dependencyModelRootYyy }); var snapshot = GetSnapshot((_tfm1, new[] { dependencyXxx1, dependencyYyy1, dependencyYyyExisting })); // Act var resultTree = await provider.BuildTreeAsync(dependenciesRoot, snapshot); // Assert var expectedFlatHierarchy = @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag= Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=DependencyExisting, FilePath=tfm1\yyy\dependencyExisting, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, FilePath=tfm1\Yyy\dependencyYyypath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag= Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, FilePath=tfm1\Xxx\dependencyXxxpath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag="; Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree)); }
public async Task WhenMultipleTargetSnapshotsWithExistingDependencies_ShouldApplyChanges() { var dependencyModelRootXxx = new TestDependencyModel { ProviderType = "Xxx", Id = "XxxDependencyRoot", Name = "XxxDependencyRoot", Caption = "XxxDependencyRoot", Resolved = true }; var dependencyXxx1 = new TestDependency { ProviderType = "Xxx", Id = "xxx\\dependency1", Path = "dependencyxxxpath", Name = "dependency1", Caption = "Dependency1", SchemaItemType = "Xxx", Resolved = true, TargetFramework = _tfm1 }; var dependencyModelRootYyy = new TestDependencyModel { ProviderType = "Yyy", Id = "YyyDependencyRoot", Name = "YyyDependencyRoot", Caption = "YyyDependencyRoot" }; var dependencyYyy1 = new TestDependency { ProviderType = "Yyy", Id = "yyy\\dependency1", Path = "dependencyyyypath", Name = "dependency1", Caption = "Dependency1", SchemaItemType = "Yyy", Resolved = true, TargetFramework = _tfm1 }; var dependencyYyyExisting = new TestDependency { ProviderType = "Yyy", Id = "yyy\\dependencyExisting", Path = "dependencyyyyExistingpath", Name = "dependencyExisting", Caption = "DependencyExisting", SchemaItemType = "Yyy", Resolved = true, TargetFramework = _tfm1 }; var dependencyModelRootZzz = new TestDependencyModel { ProviderType = "Zzz", Id = "ZzzDependencyRoot", Name = "ZzzDependencyRoot", Caption = "ZzzDependencyRoot", Resolved = true, Flags = ProjectTreeFlags.Create(ProjectTreeFlags.Common.BubbleUp) }; var dependencyAny1 = new TestDependency { ProviderType = "Zzz", Id = "ZzzDependencyAny1", Path = "ZzzDependencyAny1path", Name = "ZzzDependencyAny1", Caption = "ZzzDependencyAny1", TargetFramework = TargetFramework.Any }; var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies", Children = { new TestProjectTree { Caption = "OldRootChildToBeRemoved" }, new TestProjectTree { Caption = "YyyDependencyRoot", FilePath = "YyyDependencyRoot", Children = { new TestProjectTree { Caption = "DependencyExisting", FilePath = "yyy\\dependencyExisting" } } } } }; var targetModel1 = new TestDependencyModel { Id = "tfm1", Name = "tfm1", Caption = "tfm1" }; var targetModel2 = new TestDependencyModel { Id = "tfm2", Name = "tfm2", Caption = "tfm2" }; var provider = CreateProvider( rootModels: new[] { dependencyModelRootXxx, dependencyModelRootYyy, dependencyModelRootZzz }, targetModels: new[] { targetModel1, targetModel2 }); var snapshot = GetSnapshot( (_tfm1, new[] { dependencyXxx1, dependencyYyy1, dependencyYyyExisting }), (_tfm2, new[] { dependencyXxx1, dependencyYyy1, dependencyYyyExisting }), (TargetFramework.Any, new[] { dependencyAny1 })); // Act var resultTree = await provider.BuildTreeAsync(dependenciesRoot, snapshot); // Assert var expectedFlatHierarchy = @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag= Caption=ZzzDependencyRoot, FilePath=ZzzDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=ZzzDependencyAny1, FilePath=ZzzDependencyAny1, IconHash=325248665, ExpandedIconHash=325248817, Rule=, IsProjectItem=False, CustomTag= Caption=tfm2, FilePath=tfm2, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, FilePath=tfm1\Xxx\dependencyxxxpath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, FilePath=tfm1\Yyy\dependencyyyypath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyyyyExistingpath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=tfm1, FilePath=tfm1, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, FilePath=tfm1\Xxx\dependencyxxxpath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag= Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, FilePath=tfm1\Yyy\dependencyyyypath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag= Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyyyyExistingpath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag="; Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree)); }
public async Task WhenOneTargetSnapshotAndDependencySupportsHierarchyAndIsResolved_ShouldRead() { var dependencyModelRootYyy = new TestDependencyModel { ProviderType = "Yyy", Id = "YyyDependencyRoot", Name = "YyyDependencyRoot", Caption = "YyyDependencyRoot", Resolved = true }; var dependencyYyyExisting = new TestDependency { ProviderType = "Yyy", Id = "tfm1\\yyy\\dependencyExisting", Name = "dependencyExisting", Path = "dependencyExistingpath", Caption = "DependencyExisting", SchemaItemType = "Yyy", Resolved = true, Flags = DependencyTreeFlags.SupportsHierarchy, TargetFramework = _tfm1 }; var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies", Children = { new TestProjectTree { Caption = "YyyDependencyRoot", FilePath = "YyyDependencyRoot", Children = { new TestProjectTree { Caption = "DependencyExisting", FilePath = "tfm1\\yyy\\dependencyExisting", CustomTag = "ShouldBeCleanedSinceNodeWillBeRecreated", Flags = DependencyTreeFlags.Unresolved } } } } }; var provider = CreateProvider(rootModels: new[] { dependencyModelRootYyy }); var snapshot = GetSnapshot((_tfm1, new[] { dependencyYyyExisting })); // Act var resultTree = await provider.BuildTreeAsync(dependenciesRoot, snapshot); // Assert var expectedFlatHierarchy = @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag= Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyExistingpath, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag="; Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree)); }