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);
        }
Ejemplo n.º 2
0
        public void GrouppedByTargetTreeViewProvider_WhenFindByPathAndNeedToFindDependenciesRoot_ShouldFind()
        {
            // Arrange
            const string projectPath   = @"c:\myfolder\mysubfolder\myproject.csproj";
            var          projectFolder = Path.GetDirectoryName(projectPath);

            var treeServices         = new MockIDependenciesTreeServices();
            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement();
            var project        = UnconfiguredProjectFactory.Create(filePath: projectPath);
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var projectRoot = new TestProjectTree
            {
                Caption  = "myproject",
                FilePath = "",
                Flags    = ProjectTreeFlags.Empty
            };

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = "",
                Flags    = DependencyTreeFlags.DependenciesRootNodeFlags
            };

            var level1Child1 = new TestProjectTree
            {
                Caption  = "level1Child1",
                FilePath = @"c:\folder\level1Child1",
                Flags    = ProjectTreeFlags.Empty
            };

            var level1Child2 = new TestProjectTree
            {
                Caption  = "level1Child2",
                FilePath = @"c:\folder\level1Child2",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child21 = new TestProjectTree
            {
                Caption  = "level2Child21",
                FilePath = @"c:\folder\level2Child21",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child22 = new TestProjectTree
            {
                Caption  = "level1Child22",
                FilePath = @"c:\folder\level2Child22",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child31 = new TestProjectTree
            {
                Caption  = "level3Child31",
                FilePath = @"c:\folder\level3Child31",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child32 = new TestProjectTree
            {
                Caption  = "level3Child32",
                FilePath = @"level3Child32",
                Flags    = ProjectTreeFlags.Empty
            };

            projectRoot.Add(dependenciesRoot);

            dependenciesRoot.Add(level1Child1);
            dependenciesRoot.Add(level1Child2);

            level1Child2.Add(level2Child21);
            level1Child2.Add(level2Child22);

            level2Child22.Add(level3Child31);
            level2Child22.Add(level3Child32);

            // Act
            var provider   = new GroupedByTargetTreeViewProvider(treeServices, treeViewModelFactory, commonServices);
            var resultTree = provider.FindByPath(projectRoot, Path.Combine(projectFolder, @"level3Child32"));

            // Assert
            Assert.NotNull(resultTree);
            Assert.Equal("level3Child32", resultTree.Caption);
        }
Ejemplo n.º 3
0
        public void GrouppedByTargetTreeViewProvider_WhenMultipleTargetSnapshotsWithExistingDependencies_ShouldApplyChanges()
        {
            var tfm1   = ITargetFrameworkFactory.Implement(moniker: "tfm1");
            var tfm2   = ITargetFrameworkFactory.Implement(moniker: "tfm2");
            var tfmAny = ITargetFrameworkFactory.Implement(moniker: "any");

            var dependencyRootXxx = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Xxx"",
    ""Id"": ""XxxDependencyRoot"",
    ""Name"":""XxxDependencyRoot"",
    ""Caption"":""XxxDependencyRoot"",
    ""Resolved"":""true""
}");

            var dependencyXxx1 = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Xxx"",
    ""Id"": ""xxx\\dependency1"",
    ""Path"": ""dependencyxxxpath"",
    ""Name"":""dependency1"",
    ""Caption"":""Dependency1"",
    ""SchemaItemType"":""Xxx"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall, expandedIcon: KnownMonikers.Uninstall, targetFramework: tfm1);

            var dependencyRootYyy = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""YyyDependencyRoot"",
    ""Name"":""YyyDependencyRoot"",
    ""Caption"":""YyyDependencyRoot""
}");

            var dependencyYyy1 = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""yyy\\dependency1"",
    ""Path"": ""dependencyyyypath"",
    ""Name"":""dependency1"",
    ""Caption"":""Dependency1"",
    ""SchemaItemType"":""Yyy"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall, expandedIcon: KnownMonikers.Uninstall, targetFramework: tfm1);

            var dependencyYyyExisting = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""yyy\\dependencyExisting"",
    ""Path"": ""dependencyyyyExistingpath"",
    ""Name"":""dependencyExisting"",
    ""Caption"":""DependencyExisting"",
    ""SchemaItemType"":""Yyy"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall, expandedIcon: KnownMonikers.Uninstall, targetFramework: tfm1);

            var dependencyRootZzz = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Zzz"",
    ""Id"": ""ZzzDependencyRoot"",
    ""Name"":""ZzzDependencyRoot"",
    ""Caption"":""ZzzDependencyRoot"",
    ""Resolved"":""true""
}", flags: ProjectTreeFlags.Create(ProjectTreeFlags.Common.BubbleUp));
            var dependencyAny1    = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Zzz"",
    ""Id"": ""ZzzDependencyAny1"",
    ""Path"": ""ZzzDependencyAny1path"",
    ""Name"":""ZzzDependencyAny1"",
    ""Caption"":""ZzzDependencyAny1""
}", targetFramework: tfmAny);

            var dependencies = new List <IDependency>
            {
                dependencyXxx1,
                dependencyYyy1,
                dependencyYyyExisting
            };

            var dependenciesAny = new List <IDependency>
            {
                dependencyAny1
            };

            var oldRootChildToBeRemoved = new TestProjectTree
            {
                Caption  = "OldRootChildToBeRemoved",
                FilePath = ""
            };

            var dependencyYyyExistingTree = new TestProjectTree
            {
                Caption  = "DependencyExisting",
                FilePath = "yyy\\dependencyExisting"
            };

            var dependencyRootYyyTree = new TestProjectTree
            {
                Caption  = "YyyDependencyRoot",
                FilePath = "YyyDependencyRoot"
            };

            dependencyRootYyyTree.Add(dependencyYyyExistingTree);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = ""
            };

            dependenciesRoot.Add(oldRootChildToBeRemoved);
            dependenciesRoot.Add(dependencyRootYyyTree);

            var target1   = IDependencyFactory.FromJson(@"
{
    ""Id"": ""tfm1"",
    ""Name"":""tfm1"",
    ""Caption"":""tfm1""
}");
            var target2   = IDependencyFactory.FromJson(@"
{
    ""Id"": ""tfm2"",
    ""Name"":""tfm2"",
    ""Caption"":""tfm2""
}");
            var targetAny = IDependencyFactory.FromJson(@"
{
    ""Id"": ""any"",
    ""Name"":""any"",
    ""Caption"":""any""
}");

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: KnownMonikers.AboutBox,
                createRootViewModel: new[] { dependencyRootXxx, dependencyRootYyy, dependencyRootZzz },
                createTargetViewModel: new[] { target1, target2 });

            var testData = new Dictionary <ITargetFramework, List <IDependency> >
            {
                { tfm1, dependencies },
                { tfm2, dependencies },
                { tfmAny, dependenciesAny }
            };

            var project        = UnconfiguredProjectFactory.Create(filePath: @"c:\somefodler\someproject.csproj");
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var provider = new GroupedByTargetTreeViewProvider(
                new MockIDependenciesTreeServices(),
                treeViewModelFactory,
                commonServices);

            // Act
            var resultTree = provider.BuildTree(dependenciesRoot, GetSnapshot(testData));

            // Assert
            var expectedFlatHierarchy =
                @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag=
Caption=tfm2, FilePath=tfm2, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True
Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Yyy\dependencyyyypath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyyyyExistingpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Xxx\dependencyxxxpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
Caption=ZzzDependencyRoot, FilePath=ZzzDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=ZzzDependencyAny1, FilePath=ZzzDependencyAny1, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=tfm1, FilePath=tfm1, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=, BubbleUpFlag=True
Caption=YyyDependencyRoot, FilePath=YyyDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Yyy\dependencyyyypath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
Caption=DependencyExisting, FilePath=tfm1\Yyy\dependencyyyyExistingpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
Caption=Dependency1, FilePath=tfm1\Xxx\dependencyxxxpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
";

            Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy);
        }
Ejemplo n.º 4
0
        public void GrouppedByTargetTreeViewProvider_WheEmptySnapshotAndVisibilityMarkerNotProvided_ShouldHideSubTreeRoot()
        {
            var dependencyRootYyy          = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""YyyDependencyRoot"",
    ""Name"":""YyyDependencyRoot"",
    ""Caption"":""YyyDependencyRoot"",
    ""Resolved"":""true""
}");
            var dependencyVisibilityMarker = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""someid"",
    ""Name"":""someid"",
    ""Caption"":""someid"",
    ""Resolved"":""false"",
    ""Visible"":""false""
}");

            var dependencies = new List <IDependency>
            {
                dependencyVisibilityMarker
            };

            var dependencyRootYyyTree = new TestProjectTree
            {
                Caption  = "YyyDependencyRoot",
                FilePath = "YyyDependencyRoot"
            };

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = ""
            };

            dependenciesRoot.Add(dependencyRootYyyTree);

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: KnownMonikers.AboutBox,
                createRootViewModel: new[] { dependencyRootYyy });

            var testData = new Dictionary <ITargetFramework, List <IDependency> >
            {
                { ITargetFrameworkFactory.Implement(moniker: "tfm1"), dependencies }
            };

            var project        = UnconfiguredProjectFactory.Create(filePath: @"c:\somefodler\someproject.csproj");
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var provider = new GroupedByTargetTreeViewProvider(
                new MockIDependenciesTreeServices(),
                treeViewModelFactory,
                commonServices);

            // Act
            var resultTree = provider.BuildTree(dependenciesRoot, GetSnapshot(testData));

            // Assert
            var expectedFlatHierarchy =
                @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag=
";

            Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy);
        }
Ejemplo n.º 5
0
        public void GrouppedByTargetTreeViewProvider_WhenOneTargetSnapshotAndDependencySupportsRule_ShouldCreateRule()
        {
            var dependencyRootYyy     = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""YyyDependencyRoot"",
    ""Name"":""YyyDependencyRoot"",
    ""Caption"":""YyyDependencyRoot"",
    ""Resolved"":""true""
}");
            var dependencyYyyExisting = IDependencyFactory.FromJson(@"
{
    ""ProviderType"": ""Yyy"",
    ""Id"": ""tfm1\\yyy\\dependencyExisting"",
    ""Name"":""dependencyExisting"",
    ""Caption"":""DependencyExisting"",
    ""SchemaItemType"":""Yyy"",
    ""Resolved"":""true""
}", icon: KnownMonikers.Uninstall,
                                                                    expandedIcon: KnownMonikers.Uninstall,
                                                                    flags: DependencyTreeFlags.SupportsRuleProperties);

            var dependencies = new List <IDependency>
            {
                dependencyYyyExisting
            };

            var dependencyYyyExistingTree = new TestProjectTree
            {
                Caption  = "DependencyExisting",
                FilePath = "tfm1\\yyy\\dependencyExisting",
                Flags    = DependencyTreeFlags.ResolvedFlags
            };

            var dependencyRootYyyTree = new TestProjectTree
            {
                Caption  = "YyyDependencyRoot",
                FilePath = "YyyDependencyRoot"
            };

            dependencyRootYyyTree.Add(dependencyYyyExistingTree);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = ""
            };

            dependenciesRoot.Add(dependencyRootYyyTree);

            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(
                getDependenciesRootIcon: KnownMonikers.AboutBox,
                createRootViewModel: new[] { dependencyRootYyy });

            var testData = new Dictionary <ITargetFramework, List <IDependency> >
            {
                { ITargetFrameworkFactory.Implement(moniker: "tfm1"), dependencies }
            };

            var project        = UnconfiguredProjectFactory.Create(filePath: @"c:\somefodler\someproject.csproj");
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var provider = new GroupedByTargetTreeViewProvider(
                new MockIDependenciesTreeServices(),
                treeViewModelFactory,
                commonServices);

            // Act
            var resultTree = provider.BuildTree(dependenciesRoot, GetSnapshot(testData));

            // 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=325249260, ExpandedIconHash=325249260, Rule=Yyy, IsProjectItem=False, CustomTag=
";

            Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy);
        }
        public void WhenFindByPathAndAbsoluteNodePath_ShouldFind()
        {
            // Arrange
            var treeServices         = new MockIDependenciesTreeServices();
            var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement();
            var project        = UnconfiguredProjectFactory.Create();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = "",
                Flags    = DependencyTreeFlags.DependenciesRootNodeFlags
            };

            var level1Child1 = new TestProjectTree
            {
                Caption  = "level1Child1",
                FilePath = @"c:\folder\level1Child1",
                Flags    = ProjectTreeFlags.Empty
            };

            var level1Child2 = new TestProjectTree
            {
                Caption  = "level1Child2",
                FilePath = @"c:\folder\level1Child2",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child21 = new TestProjectTree
            {
                Caption  = "level2Child21",
                FilePath = @"c:\folder\level2Child21",
                Flags    = ProjectTreeFlags.Empty
            };

            var level2Child22 = new TestProjectTree
            {
                Caption  = "level1Child22",
                FilePath = @"c:\folder\level2Child22",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child31 = new TestProjectTree
            {
                Caption  = "level3Child31",
                FilePath = @"c:\folder\level3Child31",
                Flags    = ProjectTreeFlags.Empty
            };

            var level3Child32 = new TestProjectTree
            {
                Caption  = "level3Child32",
                FilePath = @"c:\folder\level3Child32",
                Flags    = ProjectTreeFlags.Empty
            };

            dependenciesRoot.Add(level1Child1);
            dependenciesRoot.Add(level1Child2);

            level1Child2.Add(level2Child21);
            level1Child2.Add(level2Child22);

            level2Child22.Add(level3Child31);
            level2Child22.Add(level3Child32);

            // Act
            var provider   = new GroupedByTargetTreeViewProvider(treeServices, treeViewModelFactory, commonServices);
            var resultTree = provider.FindByPath(dependenciesRoot, @"c:\folder\level3Child32");

            // Assert
            Assert.NotNull(resultTree);
            Assert.Equal("level3Child32", resultTree.Caption);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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,
                Icon            = KnownMonikers.Uninstall,
                ExpandedIcon    = KnownMonikers.Uninstall,
                TargetFramework = _tfm1
            };

            var dependencyYyy1 = new TestDependency
            {
                ProviderType    = "Yyy",
                Id              = "tfm1\\yyy\\dependency1",
                Name            = "dependency1",
                Path            = "dependencyYyypath",
                Caption         = "Dependency1",
                SchemaItemType  = "Yyy",
                Resolved        = true,
                Icon            = KnownMonikers.Uninstall,
                ExpandedIcon    = KnownMonikers.Uninstall,
                TargetFramework = _tfm1
            };

            var dependencyYyyExisting = new TestDependency
            {
                ProviderType    = "Yyy",
                Id              = "tfm1\\yyy\\dependencyExisting",
                Name            = "dependencyExisting",
                Path            = "dependencyExistingPath",
                Caption         = "DependencyExisting",
                SchemaItemType  = "Yyy",
                Resolved        = true,
                Icon            = KnownMonikers.Uninstall,
                ExpandedIcon    = KnownMonikers.Uninstall,
                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=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=False, CustomTag=
        Caption=Dependency1, FilePath=tfm1\Yyy\dependencyYyypath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=
    Caption=XxxDependencyRoot, FilePath=XxxDependencyRoot, IconHash=0, ExpandedIconHash=0, Rule=, IsProjectItem=False, CustomTag=
        Caption=Dependency1, FilePath=tfm1\Xxx\dependencyXxxpath, IconHash=325249260, ExpandedIconHash=325249260, Rule=, IsProjectItem=True, CustomTag=";

            Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree));
        }
Ejemplo n.º 9
0
        public async Task WhenOneTargetSnapshotAndDependencySupportsRule_ShouldCreateRule()
        {
            var dependencyRootYyy = new TestDependency
            {
                ProviderType = "Yyy",
                Id           = "YyyDependencyRoot",
                Name         = "YyyDependencyRoot",
                Caption      = "YyyDependencyRoot",
                Resolved     = true
            };

            var dependencyYyyExisting = new TestDependency
            {
                ProviderType   = "Yyy",
                Id             = "tfm1\\yyy\\dependencyExisting",
                Name           = "dependencyExisting",
                Caption        = "DependencyExisting",
                SchemaItemType = "Yyy",
                Resolved       = true,
                Icon           = KnownMonikers.Uninstall,
                ExpandedIcon   = KnownMonikers.Uninstall,
                Flags          = DependencyTreeFlags.SupportsRuleProperties
            };

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                Children =
                {
                    new TestProjectTree
                    {
                        Caption  = "YyyDependencyRoot",
                        FilePath = "YyyDependencyRoot",
                        Children =
                        {
                            new TestProjectTree
                            {
                                Caption  = "DependencyExisting",
                                FilePath = "tfm1\\yyy\\dependencyExisting",
                                Flags    = DependencyTreeFlags.ResolvedFlags
                            }
                        }
                    }
                }
            };

            var provider = CreateProvider(rootModels: new[] { dependencyRootYyy });

            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=325249260, ExpandedIconHash=325249260, Rule=Yyy, IsProjectItem=False, CustomTag=";

            Assert.Equal(expectedFlatHierarchy, ToTestDataString((TestProjectTree)resultTree));
        }