コード例 #1
0
        public void GroupUsersLocatorLoadsUsers()
        {
            var groupUsersLocatorFactory = new UsersLocatorFactory();
            var teamProjectServiceLocatorFactory = new ServiceLocatorFactory();
            var teamProjectCollectionConnectorFactory = new TeamProjectCollectionConnectorFactory();
            var teamProjectLocatorFactory = new TeamProjectsLocatorFactory();

            var teamProjectCollectionConnector = teamProjectCollectionConnectorFactory.New();
            var tfsTeamProjectCollection = teamProjectCollectionConnector.Connect("tfs.ges.ferlan.it", 8080, "DefaultCollection");
            var teamProjectServiceLocator = teamProjectServiceLocatorFactory.New(tfsTeamProjectCollection);

            var groupSecurityService = teamProjectServiceLocator.GroupSecurityService;
            var versionControlServer = teamProjectServiceLocator.VersionControlService;
            var teamProjectLocator = teamProjectLocatorFactory.New(teamProjectServiceLocator);
            var projects = teamProjectLocator.LocateProjects();
            var teamProject = projects.FirstOrDefault(p => p.Name.Equals("FerrariGes", StringComparison.InvariantCultureIgnoreCase));
            var applicationGroupsLocator = new GroupsLocatorFactory().New(groupSecurityService);
            var groupUsersLocator = groupUsersLocatorFactory.New(groupSecurityService, versionControlServer, teamProject, applicationGroupsLocator);

            var gruppi = applicationGroupsLocator.LocateApplicationGroups(teamProject.ArtifactUri.AbsoluteUri).ToList();
            //var gruppo = gruppi.First(g => g.DisplayName.Equals("ContributorsCodeMachine"));
            //var result = groupUsersLocator.LocateGroupUsers(gruppo);

            var file = new StreamWriter(@"c:\TFS-Users.csv");
            file.WriteLine(UserGroupAssociationPrinter.Header());

            foreach (var gruppo in gruppi)
            {

                var users = groupUsersLocator.LocateGroupUsers(gruppo).ToList();
                Console.WriteLine(String.Format("{0} - {1}", gruppo.DisplayName, users.Count()));
                foreach (var user in users)
                {
                    file.WriteLine(UserGroupAssociationPrinter.PrintUser(gruppo, user));
                }
            }

            file.Close();
            //var list = result.ToList();
            //Assert.IsTrue(list.Any());
        }
コード例 #2
0
        public void GroupUsersLocatorLoadsPermissions()
        {
            var groupUsersLocatorFactory = new UsersLocatorFactory();
            var teamProjectServiceLocatorFactory = new ServiceLocatorFactory();
            var teamProjectCollectionConnectorFactory = new TeamProjectCollectionConnectorFactory();
            var teamProjectLocatorFactory = new TeamProjectsLocatorFactory();

            var teamProjectCollectionConnector = teamProjectCollectionConnectorFactory.New();
            var tfsTeamProjectCollection = teamProjectCollectionConnector.Connect("tfs.ges.ferlan.it", 8080, "DefaultCollection");
            var teamProjectServiceLocator = teamProjectServiceLocatorFactory.New(tfsTeamProjectCollection);

            var groupSecurityService = teamProjectServiceLocator.GroupSecurityService;
            var versionControlServer = teamProjectServiceLocator.VersionControlService;
            var teamProjectLocator = teamProjectLocatorFactory.New(teamProjectServiceLocator);
            var projects = teamProjectLocator.LocateProjects();
            var teamProject = projects.FirstOrDefault(p => p.Name.Equals("FerrariGes", StringComparison.InvariantCultureIgnoreCase));
            var applicationGroupsLocator = new GroupsLocatorFactory().New(groupSecurityService);
            var groupUsersLocator = groupUsersLocatorFactory.New(groupSecurityService, versionControlServer, teamProject, applicationGroupsLocator);

            //var gruppi = applicationGroupsLocator.LocateApplicationGroups(teamProject.ArtifactUri.AbsoluteUri);
            //var gruppo = gruppi.First(g => g.DisplayName.Equals("ContributorsCodeMachine"));
            var result = groupUsersLocator.LocateActualPermissions();

            //var list = result.ToList();
            //Assert.IsTrue(list.Any());

            var file = new StreamWriter(@"c:\TFS-Permissions");
            file.WriteLine(ItemSecurityPrinter.Header());

            foreach (var itemSecurity in result)
            {
                file.WriteLine(new ItemSecurityPrinter(itemSecurity).ToString());
            }

            file.Close();
        }