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);
            }
        }
Ejemplo n.º 2
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());
            }
        }
Ejemplo n.º 3
0
        public void Constructor_CreatesCorrectSubFolderStructure(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);
            var contents     = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations);

            var folder = new CodeExplorerCustomFolderViewModel(null, path.First(), path.First(), null, ref contents);

            AssertFolderStructureIsCorrect(folder, structure);
        }
Ejemplo n.º 4
0
        public void Constructor_FolderAttributeIsCorrect(object[] parameters)
        {
            var structure  = ToFolderStructure(parameters.Cast <string>());
            var folderPath = structure.First().Folder;
            var path       = folderPath.Split(FolderExtensions.FolderDelimiter);

            var declarations = CodeExplorerTestSetup.TestProjectWithFolderStructure(structure, out _);
            var folder       = new CodeExplorerCustomFolderViewModel(null, path.First(), path.First(), null, ref declarations);

            foreach (var _ in path)
            {
                Assert.AreEqual($"'@Folder(\"{folder.FullPath}\")", folder.FolderAttribute);
                folder = folder.Children.OfType <CodeExplorerCustomFolderViewModel>().FirstOrDefault();
            }
        }
        public void Constructor_CreatesReferenceFolders(bool libraries, bool projects)
        {
            var declarations       = CodeExplorerTestSetup.GetProjectDeclarationsWithReferences(libraries, projects);
            var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project);

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

            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.AreEqual(libraries, libraryFolder != null);
            Assert.AreEqual(projects, projectFolder != null);
        }
        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));
        }
Ejemplo n.º 7
0
        public void Constructor_SetsFullPath(object[] parameters)
        {
            var structure  = ToFolderStructure(parameters.Cast <string>());
            var folderPath = structure.First().Folder;
            var path       = folderPath.Split(FolderExtensions.FolderDelimiter);

            var declarations = CodeExplorerTestSetup.TestProjectWithFolderStructure(structure, out _);
            var folder       = new CodeExplorerCustomFolderViewModel(null, path.First(), path.First(), null, ref declarations);

            var depth = 1;

            foreach (var _ in path)
            {
                Assert.AreEqual(string.Join(FolderExtensions.FolderDelimiter.ToString(), path.Take(depth++)), folder.FullPath);
                folder = folder.Children.OfType <CodeExplorerCustomFolderViewModel>().FirstOrDefault();
            }
        }
Ejemplo n.º 8
0
        public void Constructor_SetsFolderName(object[] parameters)
        {
            var structure  = ToFolderStructure(parameters.Cast <string>());
            var folderPath = structure.First().Folder;
            var path       = folderPath.Split(FolderExtensions.FolderDelimiter);

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

            using (state)
            {
                var folder = new CodeExplorerCustomFolderViewModel(null, path.First(), path.First(), null, ref declarations);

                foreach (var name in path)
                {
                    Assert.AreEqual(name, folder.Name);
                    folder = folder.Children.OfType <CodeExplorerCustomFolderViewModel>().FirstOrDefault();
                }
            }
        }