/// <summary> /// Initialize <see cref="PlanningPokerController"/> object with Scrum Team data received from server. /// </summary> /// <param name="scrumTeam">Scrum Team data received from server.</param> /// <param name="username">Name of user joining the Scrum Team.</param> /// <returns>Asynchronous operation.</returns> public Task InitializeTeam(ScrumTeam scrumTeam, string username) { if (scrumTeam == null) { throw new ArgumentNullException(nameof(scrumTeam)); } if (string.IsNullOrEmpty(username)) { throw new ArgumentNullException(nameof(username)); } if (scrumTeam.Members == null) { scrumTeam.Members = new List <TeamMember>(); } if (scrumTeam.Observers == null) { scrumTeam.Observers = new List <TeamMember>(); } ScrumTeam = scrumTeam; User = FindTeamMember(username); IsScrumMaster = User != null && User == ScrumTeam.ScrumMaster; LastMessageId = -1; if (scrumTeam.EstimationResult != null) { _memberEstimations = GetMemberEstimationList(scrumTeam.EstimationResult); } else if (scrumTeam.EstimationParticipants != null) { _memberEstimations = scrumTeam.EstimationParticipants .Where(p => p.Estimated).Select(p => new MemberEstimation(p.MemberName)).ToList(); } else { _memberEstimations = null; } IsConnected = true; _hasJoinedEstimation = scrumTeam.EstimationParticipants != null && scrumTeam.EstimationParticipants.Any(p => string.Equals(p.MemberName, User?.Name, StringComparison.OrdinalIgnoreCase)); _selectedEstimation = null; var memberCredentials = new MemberCredentials { TeamName = TeamName, MemberName = User.Name }; return(_memberCredentialsStore.SetCredentialsAsync(memberCredentials)); }
public async Task TryReconnectTeam_MemberCredentialsDoNotMatch_DoesNotReconnectTeamOnService(string teamName, string memberName) { var planningPokerService = new Mock <IPlanningPokerClient>(); var memberCredentials = new MemberCredentials { TeamName = teamName, MemberName = memberName }; var target = CreateController(planningPokerService: planningPokerService.Object, memberCredentials: memberCredentials); var result = await target.TryReconnectTeam(PlanningPokerData.TeamName, PlanningPokerData.MemberName); Assert.IsFalse(result); planningPokerService.Verify(o => o.ReconnectTeam(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>()), Times.Never()); }
private static JoinTeamController CreateController( IPlanningPokerInitializer planningPokerInitializer = null, IPlanningPokerClient planningPokerService = null, IMessageBoxService messageBoxService = null, IBusyIndicatorService busyIndicatorService = null, IUriHelper uriHelper = null, IMemberCredentialsStore memberCredentialsStore = null, bool memberExistsError = false, ScrumTeam scrumTeam = null, ReconnectTeamResult reconnectTeamResult = null, string errorMessage = null, MemberCredentials memberCredentials = null) { if (planningPokerInitializer == null) { var planningPokerInitializerMock = new Mock <IPlanningPokerInitializer>(); planningPokerInitializer = planningPokerInitializerMock.Object; } if (planningPokerService == null) { var planningPokerServiceMock = new Mock <IPlanningPokerClient>(); var joinSetup = planningPokerServiceMock.Setup(o => o.JoinTeam(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <CancellationToken>())); var reconnectSetup = planningPokerServiceMock.Setup(o => o.ReconnectTeam(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <CancellationToken>())); if (memberExistsError) { joinSetup.ThrowsAsync(new PlanningPokerException(ReconnectErrorMessage)); if (errorMessage == null) { reconnectSetup.ReturnsAsync(reconnectTeamResult); } else { reconnectSetup.ThrowsAsync(new PlanningPokerException(errorMessage)); } } else { if (errorMessage == null) { joinSetup.ReturnsAsync(scrumTeam); } else { joinSetup.ThrowsAsync(new PlanningPokerException(errorMessage)); } } planningPokerService = planningPokerServiceMock.Object; } if (messageBoxService == null) { var messageBoxServiceMock = new Mock <IMessageBoxService>(); if (memberExistsError) { SetupReconnectMessageBox(messageBoxServiceMock, true); } messageBoxService = messageBoxServiceMock.Object; } if (busyIndicatorService == null) { var busyIndicatorServiceMock = new Mock <IBusyIndicatorService>(); busyIndicatorService = busyIndicatorServiceMock.Object; } if (uriHelper == null) { var uriHelperMock = new Mock <IUriHelper>(); uriHelper = uriHelperMock.Object; } if (memberCredentialsStore == null) { var memberCredentialsStoreMock = new Mock <IMemberCredentialsStore>(); memberCredentialsStoreMock.Setup(o => o.GetCredentialsAsync()).ReturnsAsync(memberCredentials); memberCredentialsStore = memberCredentialsStoreMock.Object; } return(new JoinTeamController(planningPokerService, planningPokerInitializer, messageBoxService, busyIndicatorService, uriHelper, memberCredentialsStore)); }