public void Should_throw_exception_when_transfer_cannot_be_mapped_to_participant_status() { _eventHandler = new TransferEventHandler(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, TransferFrom = RoomType.WaitingRoom, TransferTo = RoomType.WaitingRoom, TimeStampUtc = DateTime.UtcNow }; Assert.ThrowsAsync <RoomTransferException>(() => _eventHandler.HandleAsync(callbackEvent)); // Verify messages sent to event hub clients EventHubClientMock.Verify( x => x.ParticipantStatusMessage(_eventHandler.SourceParticipant.Id, _eventHandler.SourceParticipant.Username, conference.Id, It.IsAny <ParticipantState>()), Times.Never); }
public async Task Should_send_disconnect_messages_to_participants_and_service_bus_on_participant_disconnect() { _eventHandler = new DisconnectedEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantCount = conference.Participants.Count + 1; // plus one for admin var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var callbackEvent = new CallbackEvent { EventType = EventType.Disconnected, EventId = Guid.NewGuid().ToString(), ParticipantId = participantForEvent.Id, ConferenceId = conference.Id, Reason = "Unexpected drop", TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify( x => x.ParticipantStatusMessage(participantForEvent.Id, participantForEvent.Username, conference.Id, ParticipantState.Disconnected), Times.Exactly(participantCount)); }
public async Task should_publish_remote_mute_status_to_participants_and_linked() { var participantUsername = "******"; var conference = CreateTestConference(participantUsername, true); var conferenceId = conference.Id; var participant = conference.Participants.First(x => x.Username == participantUsername); var isRemoteMuted = true; SetupEventHubClientsForAllParticipantsInConference(conference, false); ConferenceCacheMock.Setup(cache => cache.GetOrAddConferenceAsync(conference.Id, It.IsAny <Func <Task <ConferenceDetailsResponse> > >())) .Callback(async(Guid anyGuid, Func <Task <ConferenceDetailsResponse> > factory) => await factory()) .ReturnsAsync(conference); await Hub.UpdateParticipantRemoteMuteStatus(conferenceId, participant.Id, isRemoteMuted); EventHubClientMock.Verify( x => x.Group(participant.Username.ToLowerInvariant()) .ParticipantRemoteMuteMessage(participant.Id, conference.Id, isRemoteMuted), Times.Once); foreach (var lp in participant.LinkedParticipants) { var linkedPat = conference.Participants.Single(p => p.Id == lp.LinkedId); EventHubClientMock.Verify( x => x.Group(linkedPat.Username.ToLowerInvariant()) .ParticipantRemoteMuteMessage(lp.LinkedId, conference.Id, isRemoteMuted), Times.Once); } }
public async Task should_publish_hand_raised_to_all_johs_when_one_joh_is_is_raised() { var participantUsername = "******"; var conference = CreateTestConference(participantUsername, true); var conferenceId = conference.Id; var allJohs = conference.Participants.Where(x => x.IsJudicialOfficeHolder()).ToList(); var participant = conference.Participants.First(x => x.IsJudicialOfficeHolder()); var handRaised = true; SetupEventHubClientsForAllParticipantsInConference(conference, false); ConferenceCacheMock.Setup(cache => cache.GetOrAddConferenceAsync(conference.Id, It.IsAny <Func <Task <ConferenceDetailsResponse> > >())) .Callback(async(Guid anyGuid, Func <Task <ConferenceDetailsResponse> > factory) => await factory()) .ReturnsAsync(conference); await Hub.UpdateParticipantHandStatus(conferenceId, participant.Id, handRaised); var judge = conference.Participants.Single(x => x.IsJudge()); EventHubClientMock.Verify( x => x.Group(judge.Username.ToLowerInvariant()) .ParticipantHandRaiseMessage(participant.Id, conference.Id, handRaised), Times.Once); foreach (var joh in allJohs) { EventHubClientMock.Verify( x => x.Group(joh.Username.ToLowerInvariant()) .ParticipantHandRaiseMessage(joh.Id, conference.Id, handRaised), Times.Once); } }
public async Task Should_send_available_message_to_participants_and_service_bus_when_participant_leaves() { _eventHandler = new LeaveEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.Leave, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TimeStampUtc = DateTime.UtcNow, Reason = "Automated" }; await _eventHandler.HandleAsync(callbackEvent); EventHubClientMock.Verify( x => x.ParticipantStatusMessage(_eventHandler.SourceParticipant.Id, _eventHandler.SourceParticipant.Username, conference.Id, ParticipantState.Disconnected), Times.Exactly(participantCount)); }
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); }
public async Task Should_Throw_ParticipantNotFoundException_With_No_ParticipantId() { var participantUsername = "******"; var conference = CreateTestConference(participantUsername); var conferenceId = conference.Id; var participantId = Guid.Empty; var transferDirection = TransferDirection.In; ConferenceCacheMock.Setup(cache => cache.GetOrAddConferenceAsync(conference.Id, It.IsAny <Func <Task <ConferenceDetailsResponse> > >())) .Callback(async(Guid anyGuid, Func <Task <ConferenceDetailsResponse> > factory) => await factory()) .ReturnsAsync(conference); SetupEventHubClientsForAllParticipantsInConference(conference, true); await Hub.SendTransferRequest(conferenceId, participantId, transferDirection); foreach (var p in conference.Participants) { EventHubClientMock.Verify( x => x.Group(p.Username.ToLowerInvariant()) .HearingTransfer(conferenceId, participantId, transferDirection), Times.Never); } EventHubClientMock.Verify( x => x.Group(EventHub.Hub.EventHub.VhOfficersGroupName) .HearingTransfer(conferenceId, participantId, transferDirection), Times.Never); }
public async Task Should_send_available_message_to_participants_and_service_bus_when_participant_joins() { MemoryCache.Remove(TestConference.Id); var confDetail = CreateConferenceDetailsResponse(); VideoApiClientMock.Setup(x => x.GetConferenceDetailsByIdAsync(TestConference.Id)).ReturnsAsync(confDetail); _eventHandler = new JoinedEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.Joined, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); EventHubClientMock.Verify( x => x.ParticipantStatusMessage(_eventHandler.SourceParticipant.Id, _eventHandler.SourceParticipant.Username, conference.Id, ParticipantState.Available), Times.Exactly(participantCount)); VideoApiClientMock.Verify(x => x.GetConferenceDetailsByIdAsync(TestConference.Id), Times.Once); }
public async Task should_send_endpoint_connected_message_to_participants_and_admin() { _eventHandler = new EndpointJoinedEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantCount = conference.Participants.Count + 1; // plus one for admin var participantForEvent = conference.Endpoints.First(); var callbackEvent = new CallbackEvent { EventType = EventType.EndpointJoined, EventId = Guid.NewGuid().ToString(), ParticipantId = participantForEvent.Id, ConferenceId = conference.Id, Reason = "JVC Connection", TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify( x => x.EndpointStatusMessage(participantForEvent.Id, conference.Id, EndpointState.Connected), Times.Exactly(participantCount)); }
public async Task Should_send_endpoint_status_messages_to_clients(RoomType from, RoomType to, EndpointState status) { _eventHandler = new EndpointTransferEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantCount = conference.Participants.Count + 1; // plus one for admin var participantForEvent = conference.Endpoints.First(); var callbackEvent = new CallbackEvent { EventType = EventType.EndpointTransfer, EventId = Guid.NewGuid().ToString(), ParticipantId = participantForEvent.Id, TransferFrom = from.ToString(), TransferTo = to.ToString(), ConferenceId = conference.Id, Reason = "JVC Connection", TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); EventHubClientMock.Verify(x => x.EndpointStatusMessage(participantForEvent.Id, conference.Id, status), Times.Exactly(participantCount)); }
public async Task should_send_participant_status_when_transferring_from_new_consultation_room() { _eventHandler = new TransferEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.Transfer, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TransferFrom = "JudgeConsultationRoom3", TransferTo = RoomType.WaitingRoom.ToString(), TimeStampUtc = DateTime.UtcNow }; var expectedStatus = ParticipantState.Available; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify( x => x.ParticipantStatusMessage(_eventHandler.SourceParticipant.Id, _eventHandler.SourceParticipant.Username, conference.Id, expectedStatus), Times.Exactly(participantCount)); }
public async Task Should_send_participant__status_messages_to_clients_and_asb_when_transfer_occurs( RoomType from, RoomType to, ParticipantState status) { _eventHandler = new TransferEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.Transfer, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TransferFrom = from.ToString(), TransferTo = to.ToString(), TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify( x => x.ParticipantStatusMessage(_eventHandler.SourceParticipant.Id, _eventHandler.SourceParticipant.Username, conference.Id, status), Times.Exactly(participantCount)); }
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 async Task Should_send_not_signed_in_message_to_participants_and_service_bus_when_a_participant_is_signed_off() { _eventHandler = new ParticipantNotSignedInEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Participants.First(x => x.Role == Role.Individual); var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.ParticipantNotSignedIn, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, ParticipantId = participantForEvent.Id, TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); Assert.AreEqual(_eventHandler.EventType, EventType.ParticipantNotSignedIn); EventHubClientMock.Verify( x => x.ParticipantStatusMessage(_eventHandler.SourceParticipant.Id, _eventHandler.SourceParticipant.Username, conference.Id, ParticipantState.NotSignedIn), Times.Exactly(participantCount)); }
private void VerifyMessageCallCount(Conference conference, Guid participantId, ParticipantMediaStatus message, Times times) { var judge = conference.Participants.Single(x => x.IsJudge()); EventHubClientMock.Verify( x => x.Group(judge.Username.ToLowerInvariant()) .ParticipantMediaStatusMessage(participantId, conference.Id, It.Is <ParticipantMediaStatus>(s => s.IsLocalAudioMuted == message.IsLocalAudioMuted && s.IsLocalVideoMuted == message.IsLocalVideoMuted)), times); EventHubClientMock.Verify( x => x.Group(EventHub.Hub.EventHub.VhOfficersGroupName) .ParticipantMediaStatusMessage(participantId, conference.Id, message), times); }
public async Task should_not_publish_when_participant_does_not_exist() { var participantUsername = "******"; var conference = CreateTestConference(participantUsername, true); var conferenceId = conference.Id; var participantId = Guid.NewGuid(); var isRemoteMuted = true; ConferenceCacheMock.Setup(cache => cache.GetOrAddConferenceAsync(conference.Id, It.IsAny <Func <Task <ConferenceDetailsResponse> > >())) .Callback(async(Guid anyGuid, Func <Task <ConferenceDetailsResponse> > factory) => await factory()) .ReturnsAsync(conference); await Hub.UpdateParticipantRemoteMuteStatus(conferenceId, participantId, isRemoteMuted); EventHubClientMock.Verify( x => x.Group(It.IsAny <string>()) .ParticipantRemoteMuteMessage(participantId, conference.Id, isRemoteMuted), Times.Never); }
public async Task Should_send_messages_to_participants_on_help() { _eventHandler = new HelpEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var callbackEvent = new CallbackEvent { EventType = EventType.Help, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, TimeStampUtc = DateTime.UtcNow, ParticipantId = conference.Participants.First().Id }; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify(x => x.HelpMessage(conference.Id, conference.Participants.First().DisplayName)); }
public async Task Should_send_messages_to_participants_on_start() { _eventHandler = new StartEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.Start, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify(x => x.ConferenceStatusMessage(conference.Id, ConferenceStatus.InSession), Times.Exactly(participantCount)); }
public async Task Should_send_do_nothing_when_countdown_has_finished() { _eventHandler = new CountdownFinishedEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantCount = conference.Participants.Count + 1; // plus one for admin var callbackEvent = new CallbackEvent { EventType = EventType.CountdownFinished, EventId = Guid.NewGuid().ToString(), ConferenceId = conference.Id, TimeStampUtc = DateTime.UtcNow }; await _eventHandler.HandleAsync(callbackEvent); // Verify messages sent to event hub clients EventHubClientMock.Verify(x => x.CountdownFinished(conference.Id), Times.Exactly(participantCount)); }
public void Should_throw_exception_when_transfer_cannot_be_mapped_to_endpoint_status_cannot_be_derived() { _eventHandler = new EndpointTransferEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Endpoints.First(); var callbackEvent = new CallbackEvent { EventType = EventType.EndpointTransfer, EventId = Guid.NewGuid().ToString(), ParticipantId = participantForEvent.Id, ConferenceId = conference.Id, Reason = "JVC Connection", TimeStampUtc = DateTime.UtcNow }; Assert.ThrowsAsync <ArgumentException>(() => _eventHandler.HandleAsync(callbackEvent)).Message.Should() .Be($"Unable to derive state, no {nameof(callbackEvent.TransferTo)} provided (Parameter '{nameof(callbackEvent.TransferTo)}')"); EventHubClientMock.Verify(x => x.EndpointStatusMessage(participantForEvent.Id, conference.Id, It.IsAny <EndpointState>()), Times.Never); }
public void Should_throw_exception_when_transfer_cannot_be_mapped_to_endpoint_status_cannot_be_derived() { _eventHandler = new EndpointTransferEventHandler(EventHubContextMock.Object, ConferenceCache, LoggerMock.Object, VideoApiClientMock.Object); var conference = TestConference; var participantForEvent = conference.Endpoints.First(); var callbackEvent = new CallbackEvent { EventType = EventType.EndpointTransfer, EventId = Guid.NewGuid().ToString(), ParticipantId = participantForEvent.Id, ConferenceId = conference.Id, Reason = "JVC Connection", TimeStampUtc = DateTime.UtcNow }; Assert.ThrowsAsync <RoomTransferException>(() => _eventHandler.HandleAsync(callbackEvent)).Message.Should() .StartWith("Unable to process TransferEvent from").And.EndWith("to a status"); // Verify messages sent to event hub clients EventHubClientMock.Verify(x => x.EndpointStatusMessage(participantForEvent.Id, conference.Id, It.IsAny <EndpointState>()), Times.Never); }