protected override TeamModel AddTeam()
 {
     EFTeamRepository teams = new EFTeamRepository { CreateContext = GetContext };
     var newTeam = new TeamModel { Name="Team1" };
     teams.Create(newTeam);
     return newTeam;
 }
        protected void InitialiseTestObjects()
        {
            _teams = new EFTeamRepository { CreateContext = () => _connection.GetContext() };
            _users = new EFMembershipService { CreateContext = () => _connection.GetContext() };
            _repos = new EFRepositoryRepository { CreateContext = () => _connection.GetContext() };
            _roles = new EFRoleProvider { CreateContext = () => _connection.GetContext() };

            _service = new RepositoryPermissionService
            {
                Repository = _repos,
                TeamRepository = _teams,
                RoleProvider = _roles
            };

            new AutomaticUpdater().RunWithContext(_connection.GetContext());
        }
        private static void RefreshTeams(WindowsIdentity identity)
        {
            if (!String.Equals(ConfigurationManager.AppSettings["ActiveDirectoryIntegration"], "true", StringComparison.InvariantCultureIgnoreCase))
            {
                return;
            }

            if (identity.Groups != null)
            {
                var groups = identity.Groups.Select(@group => @group.Translate(typeof (NTAccount)).ToString()).ToList();

                var teamRepository = new EFTeamRepository();
                var teams = teamRepository.GetAllTeams();

                // Get current teams
                var newTeams = teams.Where(t => t.Members.Contains(identity.Name)).Select(t => t.Name).ToList();
                bool isChanged = false;

                // Remove non matching group
                foreach (var team in newTeams)
                {
                    var group = groups.SingleOrDefault(t => t == team);
                    if (group == null)
                    {
                        newTeams.Remove(team);
                        isChanged = true;
                    }
                }

                // Insert new matching group
                foreach (var group in groups)
                {
                    var team = teams.SingleOrDefault(t => t.Name == group);
                    if (team != null && newTeams.All(t => t != identity.Name))
                    {
                        newTeams.Add(team.Name);
                        isChanged = true;
                    }
                }

                if (isChanged)
                {
                    teamRepository.UpdateUserTeams(identity.Name, newTeams);
                }
            }
        }
 private TeamModel CreateTeam()
 {
     EFTeamRepository teams = new EFTeamRepository { CreateContext = GetContext };
     var newTeam = new TeamModel { Name = "Team1" };
     teams.Create(newTeam);
     return newTeam;
 }
        public void TeamMemberIsAuthorised()
        {
            var user = AddUser();
            var repoId = AddRepo("TestRepo");
            var team = CreateTeam();
            AddTeamToRepo(repoId, team);

            // Add the member to the team
            team.Members = new[] {user};
            EFTeamRepository teams = new EFTeamRepository { CreateContext = GetContext };
            teams.Update(team);

            Assert.IsTrue(CheckPermission(user.Id, repoId));
        }
 protected void InitialiseTestObjects()
 {
     _repo = new EFTeamRepository {CreateContext = () => _connection.GetContext()};
     _membershipService = new EFMembershipService { CreateContext = () => _connection.GetContext() };
     new AutomaticUpdater().RunWithContext(_connection.GetContext());
 }