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)); }
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()); } }
public static List <Declaration> TestProjectWithComponentRemoved(this List <Declaration> declarations, string moduleName) { var projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project); var removing = declarations.ToList().TestComponentDeclarations(moduleName); var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations).ToList(); return(candidates.Except(removing).ToList()); }
public static List <Declaration> TestComponentDeclarations(this List <Declaration> declarations, string moduleName) { var projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project); var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations); return(candidates.Where(declaration => declaration.DeclarationType != DeclarationType.Project && declaration.QualifiedModuleName.ComponentName.Equals(moduleName)).ToList()); }
public static List <Declaration> TestProjectWithMemberRemoved(this List <Declaration> declarations, string memberName, out Declaration componentDeclaration, DeclarationType type = DeclarationType.Member) { var projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project); var removing = declarations.ToList().TestMemberDeclarations(memberName, out var member, type); componentDeclaration = member.ParentDeclaration; var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations).ToList(); return(candidates.Except(removing).ToList()); }
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); }
public void TrackedDeclarations_ExcludesMemberEnclosedTypes(DeclarationType excluded) { var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations; // Validate test setup: if (declarations.All(declaration => declaration.DeclarationType != excluded)) { Assert.Inconclusive("DeclarationType under test not found in test declarations."); } var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project); var tracked = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations); Assert.IsFalse(tracked.Any(declaration => declaration.DeclarationType == excluded && !declaration.ParentDeclaration.DeclarationType.HasFlag(DeclarationType.Module))); }
public static List <Declaration> TestMemberDeclarations(this List <Declaration> declarations, string memberName, out Declaration memberDeclaration, DeclarationType type = DeclarationType.Member) { var member = declarations.Single(declaration => declaration.IdentifierName.Equals(memberName) && (type == DeclarationType.Member || declaration.DeclarationType == type)); var projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project); memberDeclaration = member; var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations); return(candidates.Where(declaration => ReferenceEquals(declaration, member) || ReferenceEquals(declaration.ParentDeclaration, member)).ToList()); }
public static List <Declaration> TestProjectWithComponentDeclarations(this List <Declaration> declarations, IEnumerable <string> moduleNames, out Declaration projectDeclaration) { projectDeclaration = declarations.Single(declaration => declaration.DeclarationType == DeclarationType.Project); var candidates = CodeExplorerProjectViewModel.ExtractTrackedDeclarationsForProject(projectDeclaration, ref declarations).ToList(); var output = new List <Declaration> { projectDeclaration }; foreach (var component in moduleNames) { output.AddRange(candidates.Where(declaration => declaration.DeclarationType != DeclarationType.Project && declaration.QualifiedModuleName.ComponentName.Equals(component))); } return(output); }
public void Constructor_PlacesAllTrackedDeclarations() { var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations; var projectDeclaration = declarations.First(declaration => declaration.DeclarationType == DeclarationType.Project); var results = declarations.ToList(); var project = new CodeExplorerProjectViewModel(projectDeclaration, ref declarations, null, null, CodeExplorerTestSetup.ProjectOneProvider); 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)); }