Beispiel #1
0
        public async Task Should_send_messages_to_participants_on_suspended()
        {
            var conference = TestConference;

            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.Pause,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                TimeStampUtc  = DateTime.UtcNow,
                ParticipantId = conference.Participants.First().Id
            };

            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateConferenceStatusCommand>(command =>
                                                                    command.ConferenceId == conference.Id &&
                                                                    command.ConferenceState == ConferenceState.Suspended)), Times.Once);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <AddTaskCommand>(command =>
                                                     command.ConferenceId == conference.Id &&
                                                     command.Body == "Hearing suspended")), Times.Once);
        }
        public async Task Should_send_not_signed_in_message_to_participants_and_service_bus_when_a_participant_is_not_signed_in()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);

            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.ParticipantNotSignedIn,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TimeStampUtc  = DateTime.UtcNow
            };
            var updateStatusCommand = new UpdateParticipantStatusCommand(conference.Id, participantForEvent.Id,
                                                                         ParticipantState.NotSignedIn);

            CommandHandlerMock.Setup(x => x.Handle(updateStatusCommand));

            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusCommand>(command =>
                                                                     command.ConferenceId == conference.Id &&
                                                                     command.ParticipantId == participantForEvent.Id &&
                                                                     command.ParticipantState == ParticipantState.NotSignedIn)), Times.Once);
        }
        public async Task Should_map_to_in_hearing_status_when_transfer_from_new_consultation_room_to_hearing_room()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);

            var callbackEvent = new CallbackEvent
            {
                EventType                = EventType.Transfer,
                EventId                  = Guid.NewGuid().ToString(),
                ConferenceId             = conference.Id,
                ParticipantId            = participantForEvent.Id,
                TransferFrom             = RoomType.ConsultationRoom,
                TransferredFromRoomLabel = "JudgeConsultationRoom3",
                TransferTo               = RoomType.HearingRoom,
                TransferredToRoomLabel   = RoomType.HearingRoom.ToString(),
                TimeStampUtc             = DateTime.UtcNow
            };
            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.InHearing &&
                                                                            command.Room == RoomType.HearingRoom &&
                                                                            command.RoomLabel == RoomType.HearingRoom.ToString())), Times.Once);
        }
Beispiel #4
0
        public async Task Should_update_endpoint_status_to_disconnected()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetEndpoints().First();

            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.EndpointDisconnected,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TimeStampUtc  = DateTime.UtcNow
            };
            var updateStatusCommand = new UpdateEndpointStatusAndRoomCommand(conference.Id, participantForEvent.Id,
                                                                             EndpointState.Disconnected, null);

            CommandHandlerMock.Setup(x => x.Handle(updateStatusCommand));

            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateEndpointStatusAndRoomCommand>(command =>
                                                                         command.ConferenceId == conference.Id && command.EndpointId == participantForEvent.Id &&
                                                                         command.Status == EndpointState.Disconnected && command.Room == null)), Times.Once);
        }
Beispiel #5
0
        public async Task Should_send_available_message_to_participants_and_service_bus_when_participant_joins()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);

            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.Joined,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TimeStampUtc  = DateTime.UtcNow
            };
            var updateStatusCommand = new UpdateParticipantStatusAndRoomCommand(conference.Id, participantForEvent.Id,
                                                                                ParticipantState.Available, RoomType.WaitingRoom);

            CommandHandlerMock.Setup(x => x.Handle(updateStatusCommand));

            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.Available &&
                                                                            command.Room == RoomType.WaitingRoom)), Times.Once);
        }
        public async Task Should_map_to_available_status_when_transfer_to_waiting_room_from_judge_consultation_room()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);

            QueryHandlerMock.Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(new ConsultationRoom(conference.Id, "JudgeConsultationRoom3", VirtualCourtRoomType.JudgeJOH, false));

            var callbackEvent = new CallbackEvent
            {
                EventType                = EventType.Transfer,
                EventId                  = Guid.NewGuid().ToString(),
                ConferenceId             = conference.Id,
                ParticipantId            = participantForEvent.Id,
                TransferFrom             = null,
                TransferTo               = RoomType.WaitingRoom,
                TransferredFromRoomLabel = "JudgeConsultationRoom3",
                TransferredToRoomLabel   = RoomType.WaitingRoom.ToString(),
                TimeStampUtc             = DateTime.UtcNow
            };
            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.Available &&
                                                                            command.Room == RoomType.WaitingRoom &&
                                                                            command.RoomLabel == RoomType.WaitingRoom.ToString())), Times.Once);
        }
Beispiel #7
0
        public async Task Should_successfully_clone_hearing()
        {
            var hearingId = Guid.NewGuid();
            var request   = new CloneHearingRequest {
                Dates = new List <DateTime> {
                    DateTime.Now.AddDays(2), DateTime.Now.AddDays(3)
                }
            };
            var hearing  = GetHearing("123");
            var caseName = $"{hearing.GetCases().First().Name} Day {1} of 3";

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()))
            .ReturnsAsync(hearing);

            var result = await Controller.CloneHearing(hearingId, request);

            result.Should().NotBeNull();
            var objectResult = (NoContentResult)result;

            objectResult.Should().NotBeNull();
            CommandHandlerMock.Verify(c => c.Handle(It.Is <CreateVideoHearingCommand>(c => c.ScheduledDateTime == request.Dates[0] && c.Cases[0].Name == "Case name Day 2 of 3")), Times.Once);
            CommandHandlerMock.Verify(c => c.Handle(It.Is <CreateVideoHearingCommand>(c => c.ScheduledDateTime == request.Dates[1] && c.Cases[0].Name == "Case name Day 3 of 3")), Times.Once);
            HearingServiceMock.Verify(h => h.UpdateHearingCaseName(It.Is <Guid>(g => g == hearingId), It.Is <string>(x => x == caseName)), Times.Once);
        }
        public async Task Should_not_call_command_handler_with_addtaskcommand_object_if_a_task_exists()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First();
            var callbackEvent       = new CallbackEvent
            {
                EventType     = EventType.Help,
                EventId       = Guid.NewGuid().ToString(),
                ParticipantId = participantForEvent.Id,
                ConferenceId  = conference.Id,
                TimeStampUtc  = DateTime.UtcNow,
                Reason        = "Test"
            };

            var tasks = new List <VideoApi.Domain.Task>
            {
                new VideoApi.Domain.Task(conference.Id, participantForEvent.Id, "Test", TaskType.Participant)
            };

            QueryHandlerMock.Setup(x => x.Handle <GetTasksForConferenceQuery, List <VideoApi.Domain.Task> >(
                                       It.IsAny <GetTasksForConferenceQuery>())).ReturnsAsync(tasks);

            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(x => x.Handle(It.IsAny <AddTaskCommand>()), Times.Never);
        }
        public void Should_throw_exception_when_transfer_cannot_be_mapped_to_participant_status()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.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>(() =>
                                                       _sut.HandleAsync(callbackEvent));

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusCommand>(command =>
                                                                     command.ConferenceId == conference.Id &&
                                                                     command.ParticipantId == participantForEvent.Id &&
                                                                     command.ParticipantState == It.IsAny <ParticipantState>())), Times.Never);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateConferenceStatusCommand>(command =>
                                                                    command.ConferenceId == conference.Id &&
                                                                    command.ConferenceState == ConferenceState.InSession)), Times.Never);
        }
        public async Task Should_not_transfer_endpoints_out_of_room_when_last_participant_leaves_if_transferring_to_hearing()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);
            var room = new ConsultationRoom(conference.Id, "ConsultationRoom2", VirtualCourtRoomType.Participant, false);

            room.AddEndpoint(new RoomEndpoint(Guid.NewGuid()));
            room.AddEndpoint(new RoomEndpoint(Guid.NewGuid()));
            QueryHandlerMock.Setup(x => x.Handle <GetConsultationRoomByIdQuery, ConsultationRoom>(It.IsAny <GetConsultationRoomByIdQuery>())).ReturnsAsync(room);

            var callbackEvent = new CallbackEvent
            {
                EventType                = EventType.Transfer,
                EventId                  = Guid.NewGuid().ToString(),
                ConferenceId             = conference.Id,
                ParticipantId            = participantForEvent.Id,
                TransferFrom             = null,
                TransferTo               = RoomType.HearingRoom,
                TransferredFromRoomLabel = "ConsultationRoom2",
                TransferredToRoomLabel   = RoomType.HearingRoom.ToString(),
                TimeStampUtc             = DateTime.UtcNow
            };
            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.InHearing &&
                                                                            command.Room == RoomType.HearingRoom &&
                                                                            command.RoomLabel == RoomType.HearingRoom.ToString())), Times.Once);

            _mocker.Mock <IConsultationService>().Verify(x => x.EndpointTransferToRoomAsync(conference.Id, It.IsAny <Guid>(), RoomType.WaitingRoom.ToString()), Times.Never);
        }
        public async Task Should_send_participant__status_messages_to_clients_and_asb_when_transfer_occurs(
            RoomType from, RoomType to, ParticipantState status)
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);

            var callbackEvent = new CallbackEvent
            {
                EventType     = EventType.Transfer,
                EventId       = Guid.NewGuid().ToString(),
                ConferenceId  = conference.Id,
                ParticipantId = participantForEvent.Id,
                TransferFrom  = from,
                TransferTo    = to,
                TimeStampUtc  = DateTime.UtcNow
            };
            await _sut.HandleAsync(callbackEvent);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == status &&
                                                                            command.Room == to)), Times.Once);
        }
Beispiel #12
0
        public async Task Should_successfully_remove_heartbeat_for_conferences_and_return_nocontent()
        {
            var result = await Controller.RemoveHeartbeatsForConferencesAsync();

            var typedResult = (NoContentResult)result;

            typedResult.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <RemoveHeartbeatsForConferencesCommand>()), Times.Once);
        }
        public async Task Should_close_conference_for_given_valid_conference_id()
        {
            VideoPlatformServiceMock.Setup(v => v.GetVirtualCourtRoomAsync(It.IsAny <Guid>())).ReturnsAsync((MeetingRoom)null);

            await Controller.CloseConferenceAsync(Guid.NewGuid());

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            VideoPlatformServiceMock.Verify(v => v.DeleteVirtualCourtRoomAsync(It.IsAny <Guid>()), Times.Never);
        }
        public async Task Should_close_conference_and_remove_court_room_for_given_valid_conference_id()
        {
            var meetingRoom = new MeetingRoom("admin", "judge", "participant", "node", "12345678");

            VideoPlatformServiceMock.Setup(v => v.GetVirtualCourtRoomAsync(It.IsAny <Guid>())).ReturnsAsync(meetingRoom);
            await Controller.CloseConferenceAsync(Guid.NewGuid());

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            VideoPlatformServiceMock.Verify(v => v.DeleteVirtualCourtRoomAsync(It.IsAny <Guid>()), Times.Once);
        }
        public async Task Should_close_conference_and_not_call_delete_audio_recording_application_if_audio_required_set_to_false_for_given_conference()
        {
            var response = new AudioPlatformServiceResponse(true);

            AudioPlatformServiceMock.Setup(v => v.DeleteAudioApplicationAsync(It.IsAny <Guid>())).ReturnsAsync(response);
            await Controller.CloseConferenceAsync(Guid.NewGuid());

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            AudioPlatformServiceMock.Verify(v => v.DeleteAudioApplicationAsync(It.IsAny <Guid>()), Times.Never);
        }
Beispiel #16
0
        public async Task ExecuteAndReturn_ExecutePipelineAndPassCommandInContext()
        {
            var session = CreateSession();

            var(command, _) = CommandHandlerMock.GetCommand();

            await session.ExecuteCommand(command);

            CatchCommandPipelineStep.AssertCommandContextCaptured <CommandMock>(
                context => context.Command.Id == command.Id);
        }
Beispiel #17
0
        public async Task Should_return_notfound_for_given_invalid_hearingId()
        {
            CommandHandlerMock.Setup(c => c.Handle(It.IsAny <AddEndPointToHearingCommand>())).ThrowsAsync(new HearingNotFoundException(Guid.NewGuid()));

            var result = await Controller.AddEndPointToHearingAsync(HearingId, AddEndpointRequest);

            result.Should().NotBeNull();
            var objectResult = (NotFoundObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
Beispiel #18
0
        public async Task Should_remove_endpoint_and_not_send_event()
        {
            var response = await Controller.RemoveEndPointFromHearingAsync(HearingId, Guid.NewGuid());

            response.Should().NotBeNull();
            var result = (NoContentResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <RemoveEndPointFromHearingCommand>()), Times.Once);
            EventPublisher.Verify(e => e.PublishAsync(It.IsAny <EndpointRemovedIntegrationEvent>()), Times.Never);
        }
Beispiel #19
0
        public async Task ExecuteAndReturn_ExecutePipelineAndPassConnectionInContext()
        {
            var session = CreateSession();

            var(command, _) = CommandHandlerMock.GetCommand();

            await session.ExecuteCommand(command);

            CatchCommandPipelineStep.AssertCommandContextCaptured <CommandMock>(
                // ReSharper disable once IsExpressionAlwaysTrue
                context => context.Connection is HattemSessionMock);
        }
Beispiel #20
0
        public async Task Should_return_notfound_with_conferencenotfoundexception()
        {
            CommandHandlerMock.Setup(c => c.Handle(It.IsAny <UpdateConferenceDetailsCommand>())).Throws(new ConferenceNotFoundException(Guid.NewGuid()));
            var request = new UpdateConferenceRequest();

            var result = await Controller.UpdateConferenceAsync(request);

            var typedResult = (NotFoundResult)result;

            typedResult.Should().NotBeNull();
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <UpdateConferenceDetailsCommand>()), Times.Once);
        }
Beispiel #21
0
        public async Task Should_remove_endpoint_from_hearing_for_given_hearing_and_endpoint_id()
        {
            var hearingId = Guid.NewGuid();

            EndpointId = Hearing.Endpoints.First().Id;
            var response = await Controller.RemoveEndPointFromHearingAsync(hearingId, EndpointId);

            response.Should().NotBeNull();
            var result = (NoContentResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <RemoveEndPointFromHearingCommand>()), Times.Once);
        }
Beispiel #22
0
        public async Task Should_send_disconnect_messages_to_participants_and_service_bus_on_participant_disconnect()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual);
            var callbackEvent       = new CallbackEvent
            {
                EventType     = EventType.Disconnected,
                EventId       = Guid.NewGuid().ToString(),
                ParticipantId = participantForEvent.Id,
                ConferenceId  = conference.Id,
                Reason        = "Unexpected drop",
                TimeStampUtc  = DateTime.UtcNow
            };
            var updateStatusCommand = new UpdateParticipantStatusAndRoomCommand(conference.Id, participantForEvent.Id,
                                                                                ParticipantState.Disconnected, null);

            CommandHandlerMock.Setup(x => x.Handle(updateStatusCommand));

            var addParticipantDisconnectedTask =
                new AddTaskCommand(conference.Id, conference.Id, "Disconnected", TaskType.Participant);

            CommandHandlerMock.Setup(x => x.Handle(addParticipantDisconnectedTask));

            await _sut.HandleAsync(callbackEvent);


            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <UpdateParticipantStatusAndRoomCommand>(command =>
                                                                            command.ConferenceId == conference.Id &&
                                                                            command.ParticipantId == participantForEvent.Id &&
                                                                            command.ParticipantState == ParticipantState.Disconnected &&
                                                                            command.Room == null)), Times.Once);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <AddTaskCommand>(command =>
                                                     command.ConferenceId == conference.Id &&
                                                     command.OriginId == participantForEvent.Id &&
                                                     command.TaskType == TaskType.Participant)), Times.Once);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <AddTaskCommand>(command =>
                                                     command.ConferenceId == conference.Id &&
                                                     command.OriginId == conference.Id &&
                                                     command.TaskType == TaskType.Hearing)), Times.Never);

            CommandHandlerMock.Verify(
                x => x.Handle(It.Is <AddTaskCommand>(command =>
                                                     command.ConferenceId == participantForEvent.Id &&
                                                     command.OriginId == participantForEvent.Id &&
                                                     command.TaskType == TaskType.Judge)), Times.Never);
        }
Beispiel #23
0
        public async Task Should_return_notfound_for_given_invalid_enpointId()
        {
            CommandHandlerMock.Setup(c => c.Handle(It.IsAny <RemoveEndPointFromHearingCommand>())).ThrowsAsync(new EndPointNotFoundException(Guid.NewGuid()));

            var hearingId  = Guid.NewGuid();
            var endpointId = Guid.Empty;

            var result = await Controller.RemoveEndPointFromHearingAsync(hearingId, endpointId);

            result.Should().NotBeNull();
            var objectResult = (NotFoundObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
        public async Task Should_book_kinly_conference_and_update_meeting_room_for_given_conference_id()
        {
            var audioPlatformServiceResponse = new AudioPlatformServiceResponse(true)
            {
                IngestUrl = "http://myIngestUrl.com"
            };

            SetupCallToMockRetryService(audioPlatformServiceResponse);
            VideoPlatformServiceMock.Setup(v => v.BookVirtualCourtroomAsync(It.IsAny <Guid>(), It.IsAny <bool>(), audioPlatformServiceResponse.IngestUrl, It.IsAny <IEnumerable <EndpointDto> >())).ReturnsAsync(MeetingRoom);

            await Controller.BookKinlyMeetingRoomAsync(Guid.NewGuid(), true, audioPlatformServiceResponse.IngestUrl, new EndpointDto[] {});

            VideoPlatformServiceMock.Verify(v => v.BookVirtualCourtroomAsync(It.IsAny <Guid>(), It.IsAny <bool>(), audioPlatformServiceResponse.IngestUrl, It.IsAny <IEnumerable <EndpointDto> >()), Times.Once);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <UpdateMeetingRoomCommand>()), Times.Once);
        }
        public void Be_Able_To_Handle_A_Command()
        {
            // given
            var someSpyCommand = new SomeSpyCommand();
            CommandHandlerMock commandHandlerMock = new CommandHandlerMock();

            _sut = new DefaultCommandBus();
            _sut.Register(someSpyCommand.GetType(), commandHandlerMock);

            // when
            _sut.Dispatch(someSpyCommand);

            // then
            someSpyCommand.ShouldBeCommandTypeMessage();
            commandHandlerMock.ShouldBeCalledOnce();
        }
        public async Task Should_successfully_book_new_hearing()
        {
            var response = await Controller.BookNewHearing(request);

            response.Should().NotBeNull();
            var result = (CreatedAtActionResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.Created);

            QueryHandlerMock.Verify(x => x.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>()), Times.Once);

            QueryHandlerMock.Verify(x => x.Handle <GetHearingVenuesQuery, List <HearingVenue> >(It.IsAny <GetHearingVenuesQuery>()), Times.Once);

            QueryHandlerMock.Verify(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()), Times.Once);

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CreateVideoHearingCommand>()), Times.Once);
        }
Beispiel #27
0
        public async Task Should_remove_endpoint_and_send_event()
        {
            var endpoint = Hearing.Endpoints.First();

            EndpointId = endpoint.Id;
            var response = await Controller.RemoveEndPointFromHearingAsync(HearingId, EndpointId);

            response.Should().NotBeNull();
            var result = (NoContentResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <RemoveEndPointFromHearingCommand>()), Times.Once);
            EventPublisher.Verify(
                e => e.PublishAsync(
                    It.Is <EndpointRemovedIntegrationEvent>(r => r.HearingId == HearingId && r.Sip == endpoint.Sip)),
                Times.Once);
        }
Beispiel #28
0
        public async Task Should_add_endpoint_without_matching_advocate_and_no_send_event()
        {
            var updatedHearing = GetVideoHearing(true);

            QueryHandler.Setup(q => q.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()))
            .ReturnsAsync(updatedHearing);

            var response = await Controller.AddEndPointToHearingAsync(HearingId, AddEndpointRequest);

            response.Should().NotBeNull();
            var result = (NoContentResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <AddEndPointToHearingCommand>()), Times.Once);

            EventPublisher.Verify(x => x.PublishAsync(It.IsAny <EndpointAddedIntegrationEvent>()), Times.Never);
        }
        public async Task Should_return_notfound_for_given_invalid_hearingId()
        {
            CommandHandlerMock.Setup(c => c.Handle(It.IsAny <UpdateEndPointOfHearingCommand>())).ThrowsAsync(new HearingNotFoundException(Guid.NewGuid()));

            var hearingId  = Guid.NewGuid();
            var endpointId = Guid.NewGuid();

            var result = await Controller.UpdateEndpointAsync(hearingId, endpointId, new UpdateEndpointRequest
            {
                DisplayName = "Test"
            });

            result.Should().NotBeNull();
            var objectResult = (NotFoundObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
        public async Task Should_update_endpoint_and_not_send_event()
        {
            var request = new UpdateEndpointRequest
            {
                DisplayName             = "Updated Display Name With Defence Advocate Test",
                DefenceAdvocateUsername = null
            };
            var response = await Controller.UpdateEndpointAsync(HearingId, Guid.NewGuid(), request);

            response.Should().NotBeNull();
            var result = (NoContentResult)response;

            result.StatusCode.Should().Be((int)HttpStatusCode.NoContent);
            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <UpdateEndPointOfHearingCommand>()), Times.Once);

            EventPublisher.Verify(
                x => x.PublishAsync(It.IsAny <EndpointUpdatedIntegrationEvent>()), Times.Never);
        }