public async Task ReconnectTeam_TeamAndMemberName_ReturnsScrumTeamWithEstimationFinishedAndEstimationIsNull()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.ReconnectTeam(PlanningPokerData.TeamName, PlanningPokerData.ScrumMasterName, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var estimationResult = PlanningPokerData.GetEstimationResult(scrumMasterEstimation: 8, memberEstimation: double.NaN);
            var scrumTeam        = PlanningPokerData.GetScrumTeam(member: true, state: TeamState.EstimationFinished, estimationResult: estimationResult);
            var reconnectResult  = PlanningPokerData.GetReconnectTeamResult(scrumTeam, lastMessageId: 2157483849, selectedEstimation: 8);
            var returnMessage    = new CompletionMessage(invocationId, null, reconnectResult, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(reconnectResult, result);
            AssertAvailableEstimations(result.ScrumTeam);
            Assert.IsNotNull(result.SelectedEstimation);
            Assert.AreEqual(8.0, result.SelectedEstimation.Value);
            Assert.AreEqual(8.0, result.ScrumTeam.EstimationResult[0].Estimation.Value);
            Assert.IsNull(result.ScrumTeam.EstimationResult[1].Estimation);
        }
        public async Task CreateTeam_TeamAndScrumMasterName_ReturnsScrumTeam()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.CreateTeam(PlanningPokerData.TeamName, PlanningPokerData.ScrumMasterName, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var scrumTeam     = PlanningPokerData.GetScrumTeam();
            var returnMessage = new CompletionMessage(invocationId, null, scrumTeam, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(scrumTeam, result);
            AssertAvailableEstimations(result);
        }
        public async Task JoinTeam_TeamAndObserverName_ReturnsScrumTeam()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.JoinTeam(PlanningPokerData.TeamName, PlanningPokerData.ObserverName, false, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var scrumTeam     = PlanningPokerData.GetScrumTeam(observer: true);
            var teamResult    = PlanningPokerData.GetTeamResult(scrumTeam);
            var returnMessage = new CompletionMessage(invocationId, null, teamResult, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(teamResult, result);
            AssertAvailableEstimations(result.ScrumTeam);
        }
        public async Task JoinTeam_TeamAndMemberName_ReturnsScrumTeamWithEstimationInProgress()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.JoinTeam(PlanningPokerData.TeamName, PlanningPokerData.MemberName, false, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var estimationParticipants = PlanningPokerData.GetEstimationParticipants();
            var scrumTeam     = PlanningPokerData.GetScrumTeam(member: true, state: TeamState.EstimationInProgress, estimationParticipants: estimationParticipants);
            var returnMessage = new CompletionMessage(invocationId, null, scrumTeam, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(scrumTeam, result);
            AssertAvailableEstimations(result);
        }
        public async Task JoinTeam_TeamNameAndObserverName_InvocationMessageIsSent()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.JoinTeam(PlanningPokerData.TeamName, PlanningPokerData.ObserverName, true, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var sentInvocationMessage = AssertIsInvocationMessage(sentMessage);

            Assert.AreEqual("JoinTeam", sentInvocationMessage.Target);
            var expectedArguments = new object[] { PlanningPokerData.TeamName, PlanningPokerData.ObserverName, true };

            CollectionAssert.AreEqual(expectedArguments, sentInvocationMessage.Arguments);

            var scrumTeam     = PlanningPokerData.GetScrumTeam(observer: true);
            var returnMessage = new CompletionMessage(sentInvocationMessage.InvocationId, null, scrumTeam, true);
            await fixture.ReceiveMessage(returnMessage);

            await resultTask;
        }
        public async Task ReconnectTeam_TeamAndMemberName_ReturnsScrumTeam()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.ReconnectTeam(PlanningPokerData.TeamName, PlanningPokerData.MemberName, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var scrumTeam       = PlanningPokerData.GetScrumTeam(member: true);
            var reconnectResult = PlanningPokerData.GetReconnectTeamResultJson(scrumTeam);
            var returnMessage   = new CompletionMessage(invocationId, null, reconnectResult, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(reconnectResult, result);
            AssertAvailableEstimations(result.ScrumTeam);
            Assert.IsNull(reconnectResult.SelectedEstimation);
        }
        public async Task CreateTeam_TeamNameAndScrumMaster_InvocationMessageIsSent(Deck deck)
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.CreateTeam(PlanningPokerData.TeamName, PlanningPokerData.ScrumMasterName, deck, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var sentInvocationMessage = AssertIsInvocationMessage(sentMessage);

            Assert.AreEqual("CreateTeam", sentInvocationMessage.Target);
            var expectedArguments = new object[] { PlanningPokerData.TeamName, PlanningPokerData.ScrumMasterName, deck };

            CollectionAssert.AreEqual(expectedArguments, sentInvocationMessage.Arguments);

            var scrumTeam     = PlanningPokerData.GetScrumTeam();
            var teamResult    = PlanningPokerData.GetTeamResult(scrumTeam);
            var returnMessage = new CompletionMessage(sentInvocationMessage.InvocationId, null, teamResult, true);
            await fixture.ReceiveMessage(returnMessage);

            await resultTask;
        }
        public async Task JoinTeam_TeamAndMemberName_ReturnsScrumTeamWithEstimationCanceled()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.JoinTeam(PlanningPokerData.TeamName, PlanningPokerData.MemberName, false, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var estimationResult = PlanningPokerData.GetEstimationResult(scrumMasterEstimation: 0, memberEstimation: double.NaN);
            var scrumTeam        = PlanningPokerData.GetScrumTeam(member: true, state: TeamState.EstimationCanceled, estimationResult: estimationResult);
            var returnMessage    = new CompletionMessage(invocationId, null, scrumTeam, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(scrumTeam, result);
            AssertAvailableEstimations(result);
            Assert.AreEqual(0.0, result.EstimationResult[0].Estimation.Value);
            Assert.IsNull(result.EstimationResult[1].Estimation);
        }
        public async Task ReconnectTeam_TeamAndMemberName_ReturnsScrumTeamWithEstimationInProgress()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.ReconnectTeam(PlanningPokerData.TeamName, PlanningPokerData.ScrumMasterName, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var estimationParticipants = PlanningPokerData.GetEstimationParticipants(scrumMaster: false, member: true);
            var scrumTeam       = PlanningPokerData.GetScrumTeam(member: true, state: TeamState.EstimationInProgress, estimationParticipants: estimationParticipants);
            var reconnectResult = PlanningPokerData.GetReconnectTeamResult(scrumTeam, lastMessageId: 1, selectedEstimation: null);
            var returnMessage   = new CompletionMessage(invocationId, null, reconnectResult, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(reconnectResult, result);
            AssertAvailableEstimations(result.ScrumTeam);
            Assert.IsNotNull(result.SelectedEstimation);
            Assert.IsNull(result.SelectedEstimation.Value);
        }
        public async Task JoinTeam_TeamAndMemberName_ReturnsScrumTeamWithEstimationFinishedAndEstimationIsInfinity()
        {
            await using var fixture = new PlanningPokerSignalRClientFixture();

            var resultTask = fixture.Target.JoinTeam(PlanningPokerData.TeamName, PlanningPokerData.MemberName, false, fixture.CancellationToken);

            var sentMessage = await fixture.GetSentMessage();

            var invocationId = GetInvocationId(sentMessage);

            var estimationResult = PlanningPokerData.GetEstimationResult(scrumMasterEstimation: Estimation.PositiveInfinity, memberEstimation: null);
            var scrumTeam        = PlanningPokerData.GetScrumTeam(member: true, observer: true, state: TeamState.EstimationFinished, estimationResult: estimationResult);
            var teamResult       = PlanningPokerData.GetTeamResult(scrumTeam);
            var returnMessage    = new CompletionMessage(invocationId, null, teamResult, true);
            await fixture.ReceiveMessage(returnMessage);

            var result = await resultTask;

            Assert.AreEqual(teamResult, result);
            AssertAvailableEstimations(result.ScrumTeam);
            Assert.IsTrue(double.IsPositiveInfinity(result.ScrumTeam.EstimationResult[0].Estimation.Value.Value));
            Assert.IsNull(result.ScrumTeam.EstimationResult[1].Estimation.Value);
        }