public async Task Should_return_accepted_when_request_is_sent_participant_room_type()
        {
            // Arrange
            var request = ConsultationHelper.GetStartParticipantConsultationRequest(_testConference);

            _mocker.Mock <IVideoApiClient>()
            .Setup(x => x.CreatePrivateConsultationAsync(It.IsAny <StartConsultationRequest>()))
            .ReturnsAsync(new RoomResponse {
                Label = "Room1", Locked = false
            });

            // Act
            var result = await _controller.StartConsultationAsync(request);

            // Assert
            result.Should().BeOfType <AcceptedResult>();
            _mocker.Mock <IVideoApiClient>()
            .Verify(x => x.CreatePrivateConsultationAsync(It.IsAny <StartConsultationRequest>()), Times.Once);

            _mocker.Mock <IConsultationNotifier>()
            .Verify(
                x => x.NotifyRoomUpdateAsync(_testConference, It.Is <Room>(r =>
                                                                           r.ConferenceId == _testConference.Id && r.Label == "Room1" && !r.Locked)), Times.Once);

            _mocker.Mock <IConsultationNotifier>()
            .Verify(
                x => x.NotifyConsultationRequestAsync(_testConference, "Room1", request.RequestedBy,
                                                      It.IsIn(request.InviteParticipants)), Times.Exactly(request.InviteParticipants.Length));
        }
        public async Task Should_only_join_first_successful_endpoint_first_fail()
        {
            // Arrange
            var request = ConsultationHelper.GetStartParticipantConsultationRequest(_testConference);

            request.InviteEndpoints = new[] {
                _testConference.Endpoints[0].Id, // Wrong defense advocate username
                _testConference.Endpoints[1].Id, // Valid but mocked to throw
                _testConference.Endpoints[2].Id
            };                                   // Valid
            _mocker.Mock <IVideoApiClient>()
            .Setup(x => x.CreatePrivateConsultationAsync(It.IsAny <StartConsultationRequest>())).ReturnsAsync(new RoomResponse {
                Label = "Room1", Locked = false
            });
            var apiException = new VideoApiException <ProblemDetails>("Bad Request", (int)HttpStatusCode.BadRequest,
                                                                      "", null, default, null);
        public async Task Should_only_join_first_successful_endpoint()
        {
            // Arrange
            var request = ConsultationHelper.GetStartParticipantConsultationRequest(_testConference);

            request.InviteEndpoints = new[]
            {
                _testConference.Endpoints[0].Id, // Wrong defense advocate username
                _testConference.Endpoints[1].Id, // Valid
                _testConference.Endpoints[2].Id
            };                                   // Shouldnt try
            _mocker.Mock <IVideoApiClient>()
            .Setup(x => x.CreatePrivateConsultationAsync(It.IsAny <StartConsultationRequest>()))
            .ReturnsAsync(new RoomResponse {
                Label = "Room1", Locked = false
            });

            // Act
            var result = await _controller.StartConsultationAsync(request);

            // Assert
            result.Should().BeOfType <AcceptedResult>();
            _mocker.Mock <IVideoApiClient>()
            .Verify(x => x.CreatePrivateConsultationAsync(It.IsAny <StartConsultationRequest>()), Times.Once);

            _mocker.Mock <IConsultationNotifier>()
            .Verify(
                x => x.NotifyRoomUpdateAsync(_testConference, It.Is <Room>(r =>
                                                                           r.ConferenceId == _testConference.Id && r.Label == "Room1" && !r.Locked)), Times.Once);

            _mocker.Mock <IConsultationNotifier>()
            .Verify(
                x => x.NotifyConsultationRequestAsync(_testConference, "Room1", request.RequestedBy,
                                                      It.IsIn(request.InviteParticipants)), Times.Exactly(request.InviteParticipants.Length));

            _mocker.Mock <IVideoApiClient>()
            .Verify(
                x => x.JoinEndpointToConsultationAsync(It.Is <EndpointConsultationRequest>(ecr =>
                                                                                           request.InviteEndpoints.Contains(ecr.EndpointId) && ecr.ConferenceId == _testConference.Id &&
                                                                                           ecr.RequestedById == request.RequestedBy)), Times.Once);
        }