コード例 #1
0
        public void Synchronize_RemovedComponent_HasCorrectSubFolderStructure(params object[] parameters)
        {
            var structure = ToFolderStructure(parameters.Cast <string>());
            var root      = structure.First().Folder;
            var path      = root.Split(FolderExtensions.FolderDelimiter);

            var declarations = CodeExplorerTestSetup.TestProjectWithFolderStructure(structure, out var projectDeclaration, out var state);

            using (state)
            {
                var contents =
                    CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration,
                                                                                      ref declarations);
                var component     = contents.TestComponentDeclarations(structure.Last().Name);
                var synchronizing = contents.Except(component).ToList();

                var project = new CodeExplorerProjectViewModel(projectDeclaration, ref contents, state, null, state.ProjectsProvider);
                var folder  = project.Children.OfType <CodeExplorerCustomFolderViewModel>()
                              .Single(item => item.Name.Equals(path.First()));

                project.Synchronize(ref synchronizing);

                AssertFolderStructureIsCorrect(folder, structure.Take(structure.Count - 1).ToList());
            }
        }
コード例 #2
0
        public void Synchronize_ReferenceFolderRemoved(bool libraries, bool projects)
        {
            var declarations = CodeExplorerTestSetup.GetProjectDeclarationsWithReferences(libraries, projects, out var state);

            using (state)
            {
                var updates            = declarations.ToList();
                var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

                var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, state, null, state.ProjectsProvider);

                var references = state.ProjectsProvider.Project(projectDeclaration.ProjectId).References;
                foreach (var reference in references.ToList())
                {
                    references.Remove(reference);
                }

                project.Synchronize(ref updates);

                var libraryFolder = project.Children.OfType <CodeExplorerReferenceFolderViewModel>()
                                    .SingleOrDefault(folder => folder.ReferenceKind == ReferenceKind.TypeLibrary);
                var projectFolder = project.Children.OfType <CodeExplorerReferenceFolderViewModel>()
                                    .SingleOrDefault(folder => folder.ReferenceKind == ReferenceKind.Project);

                Assert.IsNull(libraryFolder);
                Assert.IsNull(projectFolder);
            }
        }
コード例 #3
0
        public void Synchronize_PlacesAllTrackedDeclarations_AddedComponent(string component, string added)
        {
            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations
                               .TestProjectWithComponentDeclarations(new[] { component }, out var projectDeclaration);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);

            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations
                          .TestProjectWithComponentDeclarations(new[] { component, added }, out _).ToList();

            var results  = updates.ToList();
            var expected =
                CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref results)
                .Select(declaration => declaration.QualifiedName.ToString())
                .OrderBy(_ => _)
                .ToList();

            project.Synchronize(ref updates);

            var children = project.GetAllChildDeclarations();
            var actual   = children
                           .Select(declaration => declaration.QualifiedName.ToString())
                           .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
コード例 #4
0
        public void Synchronize_ClearsPassedDeclarationList_NoChanges()
        {
            var declarations       = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);
            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations;

            project.Synchronize(ref updates);

            Assert.AreEqual(0, updates.Count);
        }
コード例 #5
0
        public void Synchronize_UsesDefaultProjectFolder_NoChanges()
        {
            var declarations       = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);
            var updates            = declarations.ToList();

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);

            project.Synchronize(ref updates);

            var folder = project.Children.OfType <CodeExplorerCustomFolderViewModel>().Single();

            Assert.AreEqual(projectDeclaration.IdentifierName, folder.Name);
        }
コード例 #6
0
        public void Synchronize_ReferenceFolders_NoChanges(bool libraries, bool projects)
        {
            var declarations       = CodeExplorerTestSetup.GetProjectDeclarationsWithReferences(libraries, projects);
            var updates            = declarations.ToList();
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

            var expected = GetReferencesFromProjectDeclaration(projectDeclaration).Select(reference => reference.Name).ToList();

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null);

            project.Synchronize(ref updates);

            var actual = GetReferencesFromProjectViewModel(project).OrderBy(reference => reference.Priority).Select(reference => reference.Name);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
コード例 #7
0
        public void Synchronize_AddedComponent_SingleProjectFolderExists(string component, string added)
        {
            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations
                               .TestProjectWithComponentDeclarations(new[] { component }, out var projectDeclaration);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);

            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations
                          .TestProjectWithComponentDeclarations(new[] { component, added }, out _);

            project.Synchronize(ref updates);

            var actual = project.Children.OfType <CodeExplorerCustomFolderViewModel>()
                         .Count(folder => folder.Name.Equals(CodeExplorerTestSetup.TestProjectOneName));

            Assert.AreEqual(1, actual);
        }
コード例 #8
0
        public void Synchronize_SetsDeclarationNull_DeclarationsForDifferentProject()
        {
            var declarations       = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);

            if (project.Declaration is null)
            {
                Assert.Inconclusive("Project declaration is null. Fix test setup and see why no other tests failed.");
            }

            var updates = CodeExplorerTestSetup.TestProjectTwoDeclarations;

            project.Synchronize(ref updates);

            Assert.IsNull(project.Declaration);
        }
コード例 #9
0
        public void Synchronize_DoesNotAlterDeclarationList_DifferentProject()
        {
            var declarations       = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);
            var updates = CodeExplorerTestSetup.TestProjectTwoDeclarations;

            project.Synchronize(ref updates);

            var expected = CodeExplorerTestSetup.TestProjectTwoDeclarations
                           .Select(declaration => declaration.QualifiedName.ToString())
                           .OrderBy(_ => _);

            var actual = updates.Select(declaration => declaration.QualifiedName.ToString())
                         .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
コード例 #10
0
        public void Synchronize_RemovesComponent(string removed)
        {
            var declarations       = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);

            var updates  = CodeExplorerTestSetup.TestProjectOneDeclarations.TestProjectWithComponentRemoved(removed);
            var expected = updates.Select(declaration => declaration.QualifiedName.ToString())
                           .OrderBy(_ => _)
                           .ToList();

            project.Synchronize(ref updates);

            var actual = project.GetAllChildDeclarations()
                         .Select(declaration => declaration.QualifiedName.ToString())
                         .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
コード例 #11
0
        public void Synchronize_PlacesAllTrackedDeclarations_NoChanges()
        {
            var declarations       = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

            var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider);
            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations;
            var results = updates.ToList();

            project.Synchronize(ref updates);

            var expected =
                CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref results)
                .Select(declaration => declaration.QualifiedName.ToString())
                .OrderBy(_ => _);

            var actual = project.GetAllChildDeclarations()
                         .Select(declaration => declaration.QualifiedName.ToString())
                         .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }