public async Task InitiateDiscussionStageCommandHandler_OnReestimationStatusChange_UpdatesStageAndInvokesNotification()
        {
            // Given
            var handler = new InitiateDiscussionStageCommandHandler(this.Context, this.SessionStatusUpdateDispatcherMock);
            var request = new InitiateDiscussionStageCommand {
                SessionId = this.SessionId, IsReestimation = true
            };

            this.SystemClockMock.CurrentTimeOffset.Returns(DateTimeOffset.UnixEpoch);

            // When
            UserStory userStory = this.Context.UserStories.OrderByDescending(x => x.Id).FirstOrDefault();

            await handler.Handle(request, CancellationToken.None);

            this.RefreshObject();

            UserStory newUserStory = this.Context.UserStories.OrderByDescending(x => x.Id).FirstOrDefault();

            // Then
            Assert.That(this.Session.CurrentStage, Is.EqualTo(SessionStage.Estimation));
            Assert.That(newUserStory?.Id, Is.Not.EqualTo(userStory?.Id), "Expected new user story to be assigned");

            await this.SessionStatusUpdateDispatcherMock.Received().DispatchUpdate(Arg.Any <Session>(), CancellationToken.None);
        }
        public void InitiateDiscussionStageCommandHandler_InvalidRetroId_ThrowsNotFoundException()
        {
            // Given
            const string retroId = "not found surely :)";
            var          handler = new InitiateDiscussionStageCommandHandler(this.Context, this.RetrospectiveStatusUpdateDispatcherMock);
            var          request = new InitiateDiscussionStageCommand {
                RetroId = retroId
            };

            // When
            TestDelegate action = () => handler.Handle(request, CancellationToken.None).GetAwaiter().GetResult();

            // Then
            Assert.That(action, Throws.InstanceOf <NotFoundException>());
        }
        public async Task InitiateDiscussionStageCommandHandler_OnStatusChange_UpdatesRetroStageAndInvokesNotification()
        {
            // Given
            var handler = new InitiateDiscussionStageCommandHandler(this.Context, this.RetrospectiveStatusUpdateDispatcherMock);
            var request = new InitiateDiscussionStageCommand {
                RetroId = this.RetroId
            };

            this.SystemClockMock.CurrentTimeOffset.Returns(DateTimeOffset.UnixEpoch);

            // When
            await handler.Handle(request, CancellationToken.None);

            this.RefreshObject();

            // Then
            Assert.That(this.Retrospective.CurrentStage, Is.EqualTo(RetrospectiveStage.Discuss));

            await this.RetrospectiveStatusUpdateDispatcherMock.Received().DispatchUpdate(Arg.Any <Retrospective>(), CancellationToken.None);
        }