public async Task BuildTreeAsync_EmptySnapshot_CreatesRootNode() { // Arrange var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies" }; var snapshot = DependenciesSnapshot.Empty; // Act var resultTree = await CreateProvider().BuildTreeAsync(dependenciesRoot, snapshot); // Assert var expectedFlatHierarchy = "Caption=MyDependencies, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag="; AssertTestData(expectedFlatHierarchy, resultTree); Assert.Equal(s_rootImage.ToProjectSystemType(), resultTree.Icon); Assert.Equal(s_rootImage.ToProjectSystemType(), resultTree.ExpandedIcon); }
public async Task WhenOneTargetSnapshotWithExistingDependencies_ShouldApplyChanges() { var dependencyModelRootXxx = new TestDependencyModel { ProviderType = "Xxx", Id = "XxxDependencyRoot", OriginalItemSpec = "XxxDependencyRoot", Caption = "XxxDependencyRoot", Resolved = true }; var dependencyModelRootYyy = new TestDependencyModel { ProviderType = "Yyy", Id = "YyyDependencyRoot", OriginalItemSpec = "YyyDependencyRoot", Caption = "YyyDependencyRoot" }; var dependencyXxx1 = new TestDependency { ProviderType = "Xxx", Id = "dependency1", OriginalItemSpec = "dependency1", FilePath = "dependencyXxxpath", Caption = "Dependency1", SchemaItemType = "Xxx", Resolved = true }; var dependencyYyy1 = new TestDependency { ProviderType = "Yyy", Id = "dependency1", OriginalItemSpec = "dependency1", FilePath = "dependencyYyypath", Caption = "Dependency1", SchemaItemType = "Yyy", Resolved = true }; var dependencyYyyExisting = new TestDependency { ProviderType = "Yyy", Id = "dependencyExisting", OriginalItemSpec = "dependencyExisting", FilePath = "dependencyExistingPath", Caption = "DependencyExisting", SchemaItemType = "Yyy", Resolved = true }; var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies", Children = { new TestProjectTree { Caption = "OldRootChildToBeRemoved" }, new TestProjectTree { Caption = "YyyDependencyRoot", Children = { new TestProjectTree { Caption = "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 const string expectedFlatHierarchy = @"Caption=MyDependencies, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag= Caption=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=DependencyExisting, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag= Caption=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag="; AssertTestData(expectedFlatHierarchy, resultTree); }
public async Task WhenMultipleTargetSnapshotsWithExistingDependencies_ShouldApplyChanges() { var dependencyModelRootXxx = new TestDependencyModel { ProviderType = "Xxx", Id = "XxxDependencyRoot", OriginalItemSpec = "XxxDependencyRoot", Caption = "XxxDependencyRoot", Resolved = true }; var dependencyXxx1 = new TestDependency { ProviderType = "Xxx", Id = "dependency1", FilePath = "dependencyxxxpath", OriginalItemSpec = "dependency1", Caption = "Dependency1", SchemaItemType = "Xxx", Resolved = true }; var dependencyModelRootYyy = new TestDependencyModel { ProviderType = "Yyy", Id = "YyyDependencyRoot", OriginalItemSpec = "YyyDependencyRoot", Caption = "YyyDependencyRoot" }; var dependencyYyy1 = new TestDependency { ProviderType = "Yyy", Id = "dependency1", FilePath = "dependencyyyypath", OriginalItemSpec = "dependency1", Caption = "Dependency1", SchemaItemType = "Yyy", Resolved = true }; var dependencyYyyExisting = new TestDependency { ProviderType = "Yyy", Id = "dependencyExisting", FilePath = "dependencyyyyExistingpath", OriginalItemSpec = "dependencyExisting", Caption = "DependencyExisting", SchemaItemType = "Yyy", Resolved = true }; var dependencyModelRootZzz = new TestDependencyModel { ProviderType = "Zzz", Id = "ZzzDependencyRoot", OriginalItemSpec = "ZzzDependencyRoot", Caption = "ZzzDependencyRoot", Resolved = true, Flags = ProjectTreeFlags.Create(ProjectTreeFlags.Common.BubbleUp) }; var dependencyAny1 = new TestDependency { ProviderType = "Zzz", Id = "ZzzDependencyAny1", FilePath = "ZzzDependencyAny1path", OriginalItemSpec = "ZzzDependencyAny1", Caption = "ZzzDependencyAny1" }; var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies", Children = { new TestProjectTree { Caption = "OldRootChildToBeRemoved" }, new TestProjectTree { Caption = "YyyDependencyRoot", Children = { new TestProjectTree { Caption = "DependencyExisting", } } } } }; var targetModel1 = new TestDependencyModel { Id = "tfm1", OriginalItemSpec = "tfm1", Caption = "tfm1" }; var targetModel2 = new TestDependencyModel { Id = "tfm2", OriginalItemSpec = "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 const string expectedFlatHierarchy = @"Caption=MyDependencies, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag= Caption=ZzzDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=ZzzDependencyAny1, IconHash=325248665, ExpandedIconHash=325248817, Rule=, IsProjectItem=False, CustomTag= Caption=tfm2, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True Caption=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=DependencyExisting, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag= Caption=tfm1, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True Caption=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag= Caption=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag= Caption=Dependency1, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag= Caption=DependencyExisting, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=True, CustomTag="; AssertTestData(expectedFlatHierarchy, resultTree); }
public void WhenFindByPathAndNeedToFindDependenciesRoot_ShouldNotFind() { // Arrange var provider = CreateProvider(); var projectRoot = new TestProjectTree { Caption = "myproject", Children = { new TestProjectTree { Caption = "MyDependencies", Flags = DependencyTreeFlags.DependenciesRootNode, 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, "SomePath\\level3Child32"); // Assert Assert.Null(result); }
public async Task WhenOneTargetSnapshotAndDependencyIsResolved_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, 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 = "Untouched", 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\dependencyExisting, IconHash=325248088, ExpandedIconHash=325248260, Rule=, IsProjectItem=False, CustomTag=Untouched"; Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree)); }