Beispiel #1
0
        public void GrouppedByTargetTreeViewProvider_WhenFindByPathAndNotDependenciesRoot_ShouldDoNothing()
        {
            // 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();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

            var dependenciesRoot = new TestProjectTree
            {
                Caption  = "MyDependencies",
                FilePath = "",
                Flags    = ProjectTreeFlags.Empty
            };

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

            // Assert
            Assert.Null(resultTree);
        }
        public void WhenFindByPathAndNullNode_ShouldDoNothing()
        {
            // 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();
            var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project);

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

            // Assert
            Assert.Null(resultTree);
        }
Beispiel #3
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);
        }
        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);
        }