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 async Task should_return_judge_joh_to_waiting_room_for_valid_conference_and_room_type()
        {
            var conferenceId     = TestConference.Id;
            var participantId    = TestConference.Participants[0].Id;
            var consultationRoom = new ConsultationRoom(TestConference.Id, "ConsultationRoom", VirtualCourtRoomType.JudgeJOH, false);

            TestConference.Participants[0].CurrentConsultationRoom   = consultationRoom;
            TestConference.Participants[0].CurrentConsultationRoomId = 1;
            QueryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(
                       It.Is <GetConferenceByIdQuery>(q => q.ConferenceId == TestConference.Id)))
            .ReturnsAsync(TestConference);

            var fromRoom = "ConsultationRoom";
            var toRoom   = "WaitingRoom";
            var leaveConsultationRequest = new LeaveConsultationRequest
            {
                ConferenceId = conferenceId, ParticipantId = participantId
            };
            await Controller.LeaveConsultationAsync(leaveConsultationRequest);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>
                                        (It.IsAny <GetConferenceByIdQuery>()), Times.Once);
            ConsultationServiceMock.Verify(v => v.LeaveConsultationAsync
                                               (leaveConsultationRequest.ConferenceId, leaveConsultationRequest.ParticipantId, fromRoom, toRoom),
                                           Times.Once);
        }
        public async Task Should_return_list_of_PersonResponse_successfully()
        {
            var searchTermRequest = new SearchTermRequest("test");
            var persons           = new List <Person> {
                new Person("Mr", "Test", "Tester", "T Tester")
                {
                    ContactEmail = "*****@*****.**"
                },
                new Person("Mr", "Tester", "Test", "T Test")
                {
                    ContactEmail = "*****@*****.**"
                }
            };

            QueryHandlerMock
            .Setup(x => x.Handle <GetPersonBySearchTermQuery, List <Person> >(It.IsAny <GetPersonBySearchTermQuery>()))
            .ReturnsAsync(persons);

            var result = await Controller.PostPersonBySearchTerm(searchTermRequest);

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var personResponses = (List <PersonResponse>)objectResult.Value;

            personResponses.Count.Should().Be(2);
            personResponses[0].LastName.Should().Be("Test");
            QueryHandlerMock.Verify(x => x.Handle <GetPersonBySearchTermQuery, List <Person> >(It.IsAny <GetPersonBySearchTermQuery>()), Times.Once);
        }
        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_return_an_empty_list_if_no_records_found_for_the_give_case_number()
        {
            const string caseNumber = "TaxCase12345/33";

            var query = new SearchForHearingsQuery
            {
                CaseNumber = caseNumber
            };

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingsBySearchQuery, List <VideoHearing> >(It.IsAny <GetHearingsBySearchQuery>()))
            .ReturnsAsync((List <VideoHearing>)null);

            var result = await Controller.SearchForHearingsAsync(query);

            result.Should().NotBeNull();

            var objectResult = (OkObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var hearingDetailsResponse = (List <AudioRecordedHearingsBySearchResponse>)objectResult.Value;

            hearingDetailsResponse.Should().NotBeNull();

            QueryHandlerMock
            .Verify(x => x.Handle <GetHearingsBySearchQuery, List <VideoHearing> >(It.IsAny <GetHearingsBySearchQuery>()), 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_return_return_a_list_of_hearings_for_a_valid_case_number(string caseNumber)
        {
            var hearingsByCaseNumber = new List <VideoHearing> {
                GetHearing(caseNumber)
            };

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingsByCaseNumberQuery, List <VideoHearing> >(It.IsAny <GetHearingsByCaseNumberQuery>()))
            .ReturnsAsync(hearingsByCaseNumber);

            var result = await Controller.GetHearingsByCaseNumber(WebUtility.UrlEncode(caseNumber));

            result.Should().NotBeNull();

            var objectResult = (OkObjectResult)result;

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);

            var hearingDetailsResponse = (List <HearingsByCaseNumberResponse>)objectResult.Value;

            hearingDetailsResponse.Should().NotBeNull();

            hearingDetailsResponse[0].CaseNumber.Should().Be(caseNumber);

            QueryHandlerMock
            .Verify(x => x.Handle <GetHearingsByCaseNumberQuery, List <VideoHearing> >(It.IsAny <GetHearingsByCaseNumberQuery>()), Times.Once);
        }
Beispiel #9
0
        public void TestInitialize()
        {
            var caseType = new CaseType(1, "Civil")
            {
                CaseRoles    = CaseRoles,
                HearingTypes = new List <HearingType> {
                    new HearingType("Automated Test")
                }
            };

            QueryHandlerMock
            .Setup(x => x.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>()))
            .ReturnsAsync(caseType);

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingVenuesQuery, List <HearingVenue> >(It.IsAny <GetHearingVenuesQuery>()))
            .ReturnsAsync(new List <HearingVenue> {
                new HearingVenue(1, "Birmingham Civil and Family Justice Centre")
            });

            var hearing = GetHearing("123");

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()))
            .ReturnsAsync(hearing);
        }
Beispiel #10
0
        public async Task should_return_bad_request_when_endpoint_is_already_in_room()
        {
            var endpointWithDefenceAdvocate = TestConference.GetEndpoints().First(x => !string.IsNullOrWhiteSpace(x.DefenceAdvocate));
            var defenceAdvocate             = TestConference.GetParticipants().First(x =>
                                                                                     x.Username.Equals(endpointWithDefenceAdvocate.DefenceAdvocate,
                                                                                                       StringComparison.CurrentCultureIgnoreCase));

            var room = new ConsultationRoom(TestConference.Id, "Label", VideoApi.Domain.Enums.VirtualCourtRoomType.Participant, false);

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

            var request = new EndpointConsultationRequest()
            {
                ConferenceId  = TestConference.Id,
                EndpointId    = endpointWithDefenceAdvocate.Id,
                RequestedById = defenceAdvocate.Id,
                RoomLabel     = "Label"
            };
            var result = await Controller.StartConsultationWithEndpointAsync(request);

            var actionResult = result.As <BadRequestObjectResult>();

            actionResult.Should().NotBeNull();
            actionResult.Value.Should().Be("Room already has an active endpoint");
        }
        public async Task Should_Return_BadRequest_When_Participant_Cannot_Be_Found_In_Consultation_Room()
        {
            var conferenceId     = TestConference.Id;
            var participantId    = TestConference.Participants[0].Id;
            var consultationRoom = new ConsultationRoom(TestConference.Id, "ConsultationRoom", VirtualCourtRoomType.JudgeJOH, false);

            TestConference.Participants[0].CurrentConsultationRoom = consultationRoom;
            var fromRoom = "ConsultationRoom";
            var toRoom   = "WaitingRoom";
            var leaveConsultationRequest = new LeaveConsultationRequest
            {
                ConferenceId = conferenceId, ParticipantId = participantId
            };

            var kinlyApiException = new KinlyApiException("", (int)HttpStatusCode.BadRequest, "payload",
                                                          new Dictionary <string, IEnumerable <string> >(), new Exception());

            ConsultationServiceMock.Setup(x => x.LeaveConsultationAsync(leaveConsultationRequest.ConferenceId,
                                                                        leaveConsultationRequest.ParticipantId, fromRoom, toRoom)).ThrowsAsync(kinlyApiException);

            var result = await Controller.LeaveConsultationAsync(leaveConsultationRequest);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>
                                        (It.IsAny <GetConferenceByIdQuery>()), Times.Once);
            ConsultationServiceMock.Verify(v => v.LeaveConsultationAsync
                                               (leaveConsultationRequest.ConferenceId, leaveConsultationRequest.ParticipantId, fromRoom, toRoom),
                                           Times.Never);
            result.Should().BeOfType <BadRequestObjectResult>();
        }
Beispiel #12
0
        public void Should_log_exception_when_thrown_with_request_details()
        {
            var newRequest = RequestBuilder.Build();

            QueryHandlerMock.Setup(qh => qh.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>()))
            .Throws <Exception>();

            Assert.ThrowsAsync <Exception>(async() => await Controller.BookNewHearing(newRequest));
        }
        public async Task should_send_message_to_bqs_with_updated_hearing()
        {
            var videoHearing = GetHearing("Original Hearing");

            videoHearing.UpdateStatus(BookingStatus.Created, "initial", null);
            var request = new UpdateHearingRequest
            {
                OtherInformation         = videoHearing.OtherInformation + " Updated",
                ScheduledDuration        = 999,
                UpdatedBy                = "updated by test",
                ScheduledDateTime        = DateTime.Today.AddDays(2),
                HearingRoomName          = "Updated room name",
                HearingVenueName         = "Updated venue name",
                QuestionnaireNotRequired = false,
                AudioRecordingRequired   = true,
                Cases = null
            };
            var hearingVenueOriginal = videoHearing.HearingVenue;
            var newVenue             = new HearingVenue(111, request.HearingVenueName);
            var updatedHearing       = GetHearing("Case Update Test");

            updatedHearing.SetProtected(nameof(updatedHearing.Id), videoHearing.Id);
            updatedHearing.UpdateHearingDetails(newVenue,
                                                request.ScheduledDateTime, request.ScheduledDuration, request.HearingRoomName, request.OtherInformation,
                                                request.UpdatedBy, new List <Case>(), request.QuestionnaireNotRequired.Value,
                                                request.AudioRecordingRequired.Value);

            QueryHandlerMock
            .SetupSequence(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()))
            .ReturnsAsync(videoHearing).ReturnsAsync(updatedHearing);

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingVenuesQuery, List <HearingVenue> >(It.IsAny <GetHearingVenuesQuery>()))
            .ReturnsAsync(new List <HearingVenue> {
                hearingVenueOriginal, newVenue
            });
            var expectedResult = new HearingToDetailsResponseMapper().MapHearingToDetailedResponse(updatedHearing);

            var result = await Controller.UpdateHearingDetails(videoHearing.Id, request);

            var ob = result.As <OkObjectResult>();

            ob.Should().NotBeNull();
            ob.Value.As <HearingDetailsResponse>().Should().BeEquivalentTo(expectedResult);

            var message = SbQueueClient.ReadMessageFromQueue();
            var payload = message.IntegrationEvent.As <HearingDetailsUpdatedIntegrationEvent>();

            payload.Hearing.HearingId.Should().Be(updatedHearing.Id);
            payload.Hearing.GroupId.Should().Be(updatedHearing.SourceId.GetValueOrDefault());
            payload.Hearing.RecordAudio.Should().Be(request.AudioRecordingRequired.Value);
            payload.Hearing.ScheduledDuration.Should().Be(request.ScheduledDuration);
            payload.Hearing.ScheduledDateTime.Should().Be(request.ScheduledDateTime);
            payload.Hearing.HearingVenueName.Should().Be(request.HearingVenueName);
        }
        public async Task Should_return_error_when_creating_audio_application()
        {
            SetupCallToMockRetryService(new AudioPlatformServiceResponse(false));

            var response = await Controller.BookNewConferenceAsync(_request) as ActionResult;

            response.Should().NotBeNull();
            response.Should().BeAssignableTo <ObjectResult>();

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Never);
        }
Beispiel #15
0
        public async Task Process_ExecutePipelineAndPassQueryInContext()
        {
            var session = CreateSession();

            var(query, _) = QueryHandlerMock.GetQuery();

            await session.ProcessQuery(query);

            CatchQueryPipelineStep.AssertContextCaptured <QueryMockResult>(
                context => context.Query is QueryMock actualQuery && actualQuery.Id == query.Id);
        }
Beispiel #16
0
        public async Task Process_ExecutePipelineAndPassHandlerInContext()
        {
            var session = CreateSession();

            var(query, _) = QueryHandlerMock.GetQuery();

            await session.ProcessQuery(query);

            CatchQueryPipelineStep.AssertContextCaptured <QueryMockResult>(
                context => context.Handler is QueryHandlerAdapter <IQueryHandler <HattemSessionMock, QueryMock, QueryMockResult>, HattemSessionMock, QueryMock, QueryMockResult>);
        }
        public void QueryDispatcherShouldReturnObjectOfQueryHandler()
        {
            var resultObj = new Test(Guid.NewGuid());

            DependencyServiceMock.SetMock(new DependencyDescriptor(typeof(IQueryHandler <TestQuery, Test>),
                                                                   QueryHandlerMock.GetMock(resultObj)));

            var dispatcher = new QueryDispatcher(PerformanceCounterMock.GetMock());
            var result     = dispatcher.Execute(new TestQuery());

            result.Should().Equals(resultObj);
        }
Beispiel #18
0
        public async Task Process_ExecutePipelineAndPassConnectionInContext()
        {
            var session = CreateSession();

            var(query, _) = QueryHandlerMock.GetQuery();

            await session.ProcessQuery(query);

            CatchQueryPipelineStep.AssertContextCaptured <QueryMockResult>(
                // ReSharper disable once IsExpressionAlwaysTrue
                context => context.Connection is HattemSessionMock);
        }
Beispiel #19
0
        public async Task Should_return_not_clone_without_videohearing()
        {
            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()))
            .ReturnsAsync((VideoHearing)null);

            var result = await Controller.CloneHearing(Guid.NewGuid(), new CloneHearingRequest());

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
        }
        public async Task Should_return_notfound_with_no_matching_conference()
        {
            QueryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()))
            .ReturnsAsync((VideoApi.Domain.Conference)null);


            var result = await Controller.GetConferenceDetailsByIdAsync(Guid.NewGuid());

            var typedResult = (NotFoundResult)result;

            typedResult.Should().NotBeNull();
        }
        public async Task Should_book_kinly_conference_room_for_given_conference_id_retries()
        {
            SetupCallToMockRetryService(new AudioPlatformServiceResponse(true)
            {
                IngestUrl = "http://myIngestUrl.com"
            });
            SetupCallToMockRetryService(Guid.NewGuid());
            SetupCallToMockRetryService(true);

            await Controller.BookNewConferenceAsync(_request);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Once);
        }
Beispiel #22
0
        public async Task Should_return_badrequest_without_matching_casetype()
        {
            QueryHandlerMock
            .Setup(x => x.Handle <GetCaseTypeQuery, CaseType>(It.IsAny <GetCaseTypeQuery>()))
            .ReturnsAsync((CaseType)null);

            var result = await Controller.BookNewHearing(request);

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage(nameof(request.CaseTypeName), "Case type does not exist");
        }
        public async Task Should_book_kinly_conference_with_ingesturl_when_audio_recording_is_required_retries()
        {
            SetupCallToMockRetryService(new AudioPlatformServiceResponse(true)
            {
                IngestUrl = "http://myIngestUrl.com"
            });
            SetupCallToMockRetryService(Guid.NewGuid());
            SetupCallToMockRetryService(true);

            _request.AudioRecordingRequired = true;
            await Controller.BookNewConferenceAsync(_request);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Once);
        }
        public async Task Should_return_500_when_error_saving_conference()
        {
            SetupCallToMockRetryService(new AudioPlatformServiceResponse(true)
            {
                IngestUrl = "http://myIngestUrl.com"
            });
            SetupCallToMockRetryService(Guid.Empty);

            var response = await Controller.BookNewConferenceAsync(_request) as ActionResult;

            response.Should().NotBeNull();
            response.Should().BeAssignableTo <ObjectResult>();

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Never);
        }
        public async Task Should_leave_private_consultation_with_valid_conference_and_room_type()
        {
            var conferenceId = TestConference.Id;
            var participant  = TestConference.GetParticipants()[1];

            var leaveConsultationRequest = new LeaveConsultationRequest {
                ConferenceId  = conferenceId,
                ParticipantId = participant.Id
            };

            await Controller.LeaveConsultationAsync(leaveConsultationRequest);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Once);
            ConsultationServiceMock.Verify(v => v.LeaveConsultationAsync(TestConference.Id, leaveConsultationRequest.ParticipantId, participant.GetCurrentRoom(), RoomType.WaitingRoom.ToString()), Times.Once);
            ConsultationServiceMock.VerifyNoOtherCalls();
        }
Beispiel #26
0
        public async Task Should_get_list_of_expired_conferences_with_audiorecording()
        {
            var conferences = await Controller.GetExpiredAudiorecordingConferencesAsync();

            QueryHandlerMock
            .Verify(x => x.Handle <GetExpiredAudiorecordingConferencesQuery, List <VideoApi.Domain.Conference> >(It.IsAny <GetExpiredAudiorecordingConferencesQuery>()), Times.Once);

            var result = (OkObjectResult)conferences;

            result.StatusCode.Should().Be((int)HttpStatusCode.OK);
            result.Value.Should().NotBeNull();
            var results = result.Value as IEnumerable <ExpiredConferencesResponse>;

            results.Should().NotBeNull();
            results.Count().Should().Be(1);
        }
Beispiel #27
0
        public async Task Should_return_notfound_with_no_video_hearing()
        {
            var hearingId = Guid.NewGuid();

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

            var result = await Controller.GetHearingDetailsById(hearingId);

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            QueryHandlerMock.Verify(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()), Times.Once);
        }
Beispiel #28
0
        public async Task Should_leave_private_consultation_with_valid_conference_and_room_type()
        {
            var conferenceId = TestConference.Id;
            var request      = TestConference.GetParticipants()[1];

            var leaveConsultationRequest = new LeaveConsultationRequest {
                ConferenceId  = conferenceId,
                ParticipantId = request.Id
            };

            await Controller.LeavePrivateConsultationAsync(leaveConsultationRequest);

            QueryHandlerMock.Verify(q => q.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()), Times.Once);
            VideoPlatformServiceMock.Verify(v => v.StopPrivateConsultationAsync(TestConference, RoomType.ConsultationRoom1), Times.Once);
            VideoPlatformServiceMock.VerifyNoOtherCalls();
        }
Beispiel #29
0
        public async Task Should_return_notfound_with_no_matching_person()
        {
            var username = "******";

            QueryHandlerMock
            .Setup(x => x.Handle <GetPersonByUsernameQuery, Person>(It.IsAny <GetPersonByUsernameQuery>()))
            .ReturnsAsync((Person)null);

            var result = await Controller.GetPersonByUsername(username);

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            QueryHandlerMock.Verify(x => x.Handle <GetPersonByUsernameQuery, Person>(It.IsAny <GetPersonByUsernameQuery>()), Times.Once);
        }
Beispiel #30
0
        public async Task Should_return_badrequest_without_matching_hearingvenue()
        {
            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingVenuesQuery, List <HearingVenue> >(It.IsAny <GetHearingVenuesQuery>()))
            .ReturnsAsync(new List <HearingVenue> {
                new HearingVenue(1, "Not matching")
            });

            var result = await Controller.BookNewHearing(request);

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage(nameof(request.HearingVenueName), "Hearing venue does not exist");
        }