private TeamAggregate GetValidTeam() { return(TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember }, new List <TournamentId>())); }
public void validate_member_deletion_should_work_if_same_user() { var targetedMember = GetCommonMember(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember, targetedMember }, new List <TournamentId>()); team.ValidateMemberDeletionByMember(targetedMember.Id, targetedMember.Id); }
public void add_member_should_throw_if_user_already_exists() { var existingUser = GetCommonMember(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember, existingUser }, new List <TournamentId>()); Assert.Throws <DomainException>(() => team.AddMember(existingUser)); }
public void leave_not_joined_tournament_should_throw() { var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember }, new List <TournamentId> { TestsHelper.GetTournamentId() }); Assert.Throws <DomainException>(() => team.LeaveTournament(TestsHelper.GetTournamentId(), _adminMember.Id)); }
public void remove_member_should_work() { var targetedMember = GetCommonMember(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember, targetedMember }, new List <TournamentId>()); team.RemoveMember(targetedMember.Id); Assert.AreEqual(1, team.Members.Count); CollectionAssert.DoesNotContain(team.Members, targetedMember); }
public void elevate_member_should_work() { var targetMember = GetCommonMember(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember, targetMember }, new List <TournamentId>()); team.ElevateMember(targetMember.Id); Assert.AreEqual(true, targetMember.IsAdmin); Assert.AreEqual(false, _adminMember.IsAdmin); }
public void leave_tournament_should_work() { var existingTournamentId = TestsHelper.GetTournamentId(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember }, new List <TournamentId> { existingTournamentId }); team.LeaveTournament(existingTournamentId, _adminMember.Id); CollectionAssert.DoesNotContain(team.TournamentIds, existingTournamentId); }
public void leave_tournament_without_admin_account_should_throw() { var commonMember = GetCommonMember(); var existingTournamentId = TestsHelper.GetTournamentId(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember, commonMember }, new List <TournamentId> { existingTournamentId }); Assert.Throws <DomainException>(() => team.LeaveTournament(existingTournamentId, commonMember.Id)); }
public void validate_member_deletion_should_throw_if_not_admin_and_not_same_user() { var noRightsMember = GetCommonMember(); var targetedMember = GetCommonMember(); var team = TeamAggregate.Restore(_teamId, _teamName, new List <MemberEntity> { _adminMember, noRightsMember, targetedMember }, new List <TournamentId>()); Assert.Throws <DomainException>(() => { team.ValidateMemberDeletionByMember(noRightsMember.Id, targetedMember.Id); }); }
private Task <TeamAggregate> ToEntity(Team team) { var aggregate = TeamAggregate.Restore( new TeamId(team.Id), team.Name, team.UserTeams .Where(uT => uT.LeaveDate == null && !uT.User.IsDeleted) .Select(uT => new MemberEntity(new UserId(uT.UserId), uT.IsAdmin)) .ToList(), team.ActiveParticipations .Select(p => new TournamentId(p.Tournament.Id)) .Distinct() .ToList() ); return(aggregate.ToTask()); }