public async Task should_join_jvs_to_consultation_when_vho_call_starts()
        {
            // Arrange
            _eventHandler = new VhOfficerCallEventHandler(EventHubContextMock.Object, ConferenceCache,
                                                          LoggerMock.Object, VideoApiClientMock.Object);

            var conference       = TestConference;
            var endpointForEvent = conference.Endpoints.First();


            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.VhoCall,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = endpointForEvent.Id,
                TransferTo    = "ConsultationRoom1",
                TimeStampUtc  = DateTime.UtcNow
            };

            // Act
            await _eventHandler.HandleAsync(callbackEvent);

            // Assert
            VideoApiClientMock.Verify(x => x.JoinEndpointToConsultationAsync(It.Is <EndpointConsultationRequest>(r =>
                                                                                                                 r.ConferenceId == conference.Id &&
                                                                                                                 r.RequestedById == Guid.Empty &&
                                                                                                                 r.EndpointId == endpointForEvent.Id &&
                                                                                                                 r.RoomLabel == callbackEvent.TransferTo)), Times.Once);
        }
        public async Task should_send_consultation_message_when_vho_call_starts()
        {
            _eventHandler = new VhOfficerCallEventHandler(EventHubContextMock.Object, ConferenceCache,
                                                          LoggerMock.Object, VideoApiClientMock.Object);

            var conference          = TestConference;
            var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual);


            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.VhoCall,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TransferTo    = "ConsultationRoom1",
                TimeStampUtc  = DateTime.UtcNow
            };

            await _eventHandler.HandleAsync(callbackEvent);

            // Verify messages sent to event hub clients
            EventHubClientMock.Verify(
                x => x.RequestedConsultationMessage(conference.Id, callbackEvent.TransferTo, It.IsAny <Guid>(),
                                                    _eventHandler.SourceParticipant.Id), Times.Once);
        }
Esempio n. 3
0
        public async Task Should_raise_admin_consultation_message(RoomType?transferTo)
        {
            _eventHandler = new VhOfficerCallEventHandler(EventHubContextMock.Object, ConferenceCache,
                                                          LoggerMock.Object, VideoApiClientMock.Object);

            var conference          = TestConference;
            var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual);


            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.Transfer,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TransferTo    = transferTo,
                TimeStampUtc  = DateTime.UtcNow
            };

            await _eventHandler.HandleAsync(callbackEvent);

            EventHubClientMock.Verify(x =>
                                      x.AdminConsultationMessage(conference.Id, transferTo.Value,
                                                                 participantForEvent.Username.ToLowerInvariant(), null),
                                      Times.Once);
        }
        public void Should_throw_exception_when_transfer_to_is_not_a_consultation_room(RoomType?transferTo)
        {
            _eventHandler = new VhOfficerCallEventHandler(EventHubContextMock.Object, ConferenceCache,
                                                          LoggerMock.Object, VideoApiClientMock.Object);

            var conference          = TestConference;
            var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual);


            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.Transfer,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TransferTo    = transferTo?.ToString(),
                TimeStampUtc  = DateTime.UtcNow
            };

            var exception =
                Assert.ThrowsAsync <ArgumentException>(async() => await _eventHandler.HandleAsync(callbackEvent));

            exception.Message.Should().Be("No consultation room provided");
        }