Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlanningPokerController" /> class.
 /// </summary>
 /// <param name="planningPokerService">Planning poker client to send messages to server.</param>
 /// <param name="busyIndicator">Service to show busy indicator, when operation is in progress.</param>
 /// <param name="memberCredentialsStore">Service to save and load member credentials.</param>
 public PlanningPokerController(
     IPlanningPokerClient planningPokerService,
     IBusyIndicatorService busyIndicator,
     IMemberCredentialsStore memberCredentialsStore)
 {
     _planningPokerService   = planningPokerService ?? throw new ArgumentNullException(nameof(planningPokerService));
     _busyIndicator          = busyIndicator ?? throw new ArgumentNullException(nameof(busyIndicator));
     _memberCredentialsStore = memberCredentialsStore ?? throw new ArgumentNullException(nameof(memberCredentialsStore));
 }
Пример #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JoinTeamController"/> class.
 /// </summary>
 /// <param name="planningPokerService">Planning poker client to create Scrum Team on server.</param>
 /// <param name="planningPokerInitializer">Objects that initialize new Planning Poker game.</param>
 /// <param name="messageBoxService">Service to display message to user.</param>
 /// <param name="busyIndicatorService">Service to display that operation is in progress.</param>
 /// <param name="uriHelper">Service to navigate to specified URL.</param>
 /// <param name="memberCredentialsStore">Service to save and load member credentials.</param>
 public JoinTeamController(
     IPlanningPokerClient planningPokerService,
     IPlanningPokerInitializer planningPokerInitializer,
     IMessageBoxService messageBoxService,
     IBusyIndicatorService busyIndicatorService,
     IUriHelper uriHelper,
     IMemberCredentialsStore memberCredentialsStore)
 {
     _planningPokerService     = planningPokerService ?? throw new ArgumentNullException(nameof(planningPokerService));
     _planningPokerInitializer = planningPokerInitializer ?? throw new ArgumentNullException(nameof(planningPokerInitializer));
     _messageBoxService        = messageBoxService ?? throw new ArgumentNullException(nameof(messageBoxService));
     _busyIndicatorService     = busyIndicatorService ?? throw new ArgumentNullException(nameof(busyIndicatorService));
     _uriHelper = uriHelper ?? throw new ArgumentNullException(nameof(uriHelper));
     _memberCredentialsStore = memberCredentialsStore ?? throw new ArgumentNullException(nameof(memberCredentialsStore));
 }
Пример #3
0
        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));
        }