示例#1
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_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_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);
        }
示例#4
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);
        }
        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);
        }
        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_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_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);
        }
示例#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");
        }
示例#11
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_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();
        }
示例#14
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);
        }
示例#15
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");
        }
示例#16
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");
        }
示例#17
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);
        }
示例#18
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);
        }
示例#19
0
        public async Task Should_return_empty_list_of_suitability_answers_if_no_hearings()
        {
            var userName = "******";

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

            var result = await Controller.GetPersonSuitabilityAnswers(userName);

            result.Should().NotBeNull();
            var objectResult = result as ObjectResult;
            var data         = (List <PersonSuitabilityAnswerResponse>)(objectResult.Value);

            data.Count.Should().Be(0);
            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
示例#20
0
        public async Task Should_return_notfound_with_no_matching_conference()
        {
            var request = new UpdateConferenceRequest
            {
                HearingRefId = Guid.NewGuid(),
            };

            QueryHandlerMock
            .Setup(x => x.Handle <GetNonClosedConferenceByHearingRefIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetNonClosedConferenceByHearingRefIdQuery>()))
            .ReturnsAsync((VideoApi.Domain.Conference)null);


            var result = await Controller.UpdateConferenceAsync(request);

            var typedResult = (NotFoundResult)result;

            typedResult.Should().NotBeNull();
        }
示例#21
0
        public async Task Should_return_badrequest_without_valid_videohearing()
        {
            var hearing = GetHearing("123");

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

            var result = await Controller.CloneHearing(Guid.NewGuid(), new CloneHearingRequest { Dates = new List <DateTime> {
                                                                                                     DateTime.Now.AddYears(1)
                                                                                                 } });

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.BadRequest);
            ((SerializableError)objectResult.Value).ContainsKeyAndErrorMessage("Dates", "Dates cannot be before original hearing");
        }
        public async Task Should_return_ok_result_and_many_judges_only_from_multiple_conferences()
        {
            var conferences = new List <VideoApi.Domain.Conference>();

            conferences.AddRange(Enumerable.Range(1, 5).Select(x => BuildDefaultConference()));

            QueryHandlerMock
            .Setup(x => x.Handle <GetJudgesInHearingsTodayQuery, List <VideoApi.Domain.Conference> >(It.IsAny <GetJudgesInHearingsTodayQuery>()))
            .ReturnsAsync(conferences);

            var result = (OkObjectResult)await Controller.GetJudgesInHearingsTodayAsync();

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

            results.Should().NotBeNull();
            results.Count().Should().Be(5);
        }
        public void Should_throw_exception_when_conference_does_not_exist()
        {
            QueryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, Conference>(It.IsAny <GetConferenceByIdQuery>()))
            .ReturnsAsync((Conference)null);

            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
            };

            Assert.ThrowsAsync <ConferenceNotFoundException>(() =>
                                                             _sut.HandleAsync(callbackEvent));
        }
示例#24
0
        public async Task Should_return_list_of_usernames_for_old_hearings()
        {
            var usernameList = new List <string> {
                "*****@*****.**", "*****@*****.**", "*****@*****.**"
            };

            QueryHandlerMock
            .Setup(x => x.Handle <GetPersonsByClosedHearingsQuery, List <string> >(It.IsAny <GetPersonsByClosedHearingsQuery>()))
            .ReturnsAsync(usernameList);

            var result = await Controller.GetPersonByClosedHearings();

            result.Should().NotBeNull();
            var objectResult = result as ObjectResult;
            var response     = (UserWithClosedConferencesResponse)(objectResult.Value);

            response.Usernames.Count.Should().Be(3);
            QueryHandlerMock
            .Verify(x => x.Handle <GetPersonsByClosedHearingsQuery, List <string> >(It.IsAny <GetPersonsByClosedHearingsQuery>()), Times.Once);
        }
示例#25
0
        public async Task Should_return_PersonResponse_successfully()
        {
            var username = "******";

            QueryHandlerMock
            .Setup(x => x.Handle <GetPersonByUsernameQuery, Person>(It.IsAny <GetPersonByUsernameQuery>()))
            .ReturnsAsync(new Person("Mr", "Test", "Tester", "T Tester"));

            var result = await Controller.GetPersonByUsername(username);

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

            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
            var personResponse = (PersonResponse)objectResult.Value;

            personResponse.Should().NotBeNull();
            personResponse.LastName.Should().Be("Tester");
            QueryHandlerMock.Verify(x => x.Handle <GetPersonByUsernameQuery, Person>(It.IsAny <GetPersonByUsernameQuery>()), Times.Once);
        }
示例#26
0
        public async Task Should_return_empty_list_of_suitability_answers_if_not_found_username()
        {
            var videoHearing = TestData(false);

            QueryHandlerMock
            .Setup(x => x.Handle <GetHearingsByUsernameQuery, List <VideoHearing> >(It.IsAny <GetHearingsByUsernameQuery>()))
            .ReturnsAsync(new List <VideoHearing> {
                videoHearing
            });
            var userName = videoHearing.Participants.First(p => p is Individual).Person.Username;
            var result   = await Controller.GetPersonSuitabilityAnswers(userName);

            result.Should().NotBeNull();

            var objectResult = result as ObjectResult;
            var data         = (List <PersonSuitabilityAnswerResponse>)(objectResult.Value);

            data.Count.Should().BeGreaterThan(0);
            data[0].Answers.Count.Should().Be(0);
            objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK);
        }
示例#27
0
        public async Task Should_return_badrequest_without_matching_hearingtype()
        {
            var caseType = new CaseType(1, "Civil")
            {
                CaseRoles    = CaseRoles,
                HearingTypes = new List <HearingType> {
                    new HearingType("Not matching")
                }
            };

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

            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.HearingTypeName), "Hearing type does not exist");
        }
        public async Task Should_transfer_endpoints_out_of_room_when_defense_advocate_participant_leaves_and_room_not_empty()
        {
            var conference          = TestConference;
            var participantForEvent = conference.GetParticipants().First(x => x.UserRole == UserRole.Representative && x.Username == "*****@*****.**");
            var room = new ConsultationRoom(conference.Id, "ConsultationRoom2", VirtualCourtRoomType.Participant, false);

            room.AddParticipant(new RoomParticipant(Guid.NewGuid()));
            room.AddParticipant(new RoomParticipant(Guid.NewGuid()));
            foreach (var endpoint in conference.GetEndpoints())
            {
                room.AddEndpoint(new RoomEndpoint(endpoint.Id));
            }

            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.WaitingRoom,
                TransferredFromRoomLabel = "ConsultationRoom2",
                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);

            _mocker.Mock <IConsultationService>().Verify(x => x.EndpointTransferToRoomAsync(conference.Id, It.IsAny <Guid>(), RoomType.WaitingRoom.ToString()), Times.Once);
        }
        public async Task Should_close_conference_and_delete_audio_recording_application_if_audio_files_exist_and_actual_start_date_is_null()
        {
            TestConference.AudioRecordingRequired = true;
            QueryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()))
            .ReturnsAsync(TestConference);
            var response = new AudioPlatformServiceResponse(true);

            AudioPlatformServiceMock.Setup(v => v.DeleteAudioApplicationAsync(It.IsAny <Guid>())).ReturnsAsync(response);
            AzureStorageServiceFactoryMock.Setup(x => x.Create(AzureStorageServiceType.Vh)).Returns(AzureStorageServiceMock.Object);


            AzureStorageServiceMock.Setup(x => x.GetAllBlobNamesByFilePathPrefix(It.IsAny <string>()))
            .ReturnsAsync(new List <string> {
                $"{TestConference.HearingRefId.ToString()}.mp4"
            });

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

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            AudioPlatformServiceMock.Verify(v => v.DeleteAudioApplicationAsync(It.IsAny <Guid>()), Times.Once);
        }
        public async Task Should_close_conference_and_not_call_delete_audio_recording_application_if_audio_recording_file_not_found()
        {
            TestConference.AudioRecordingRequired = true;
            TestConference.UpdateConferenceStatus(VideoApi.Domain.Enums.ConferenceState.InSession);

            QueryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>(It.IsAny <GetConferenceByIdQuery>()))
            .ReturnsAsync(TestConference);
            AzureStorageServiceFactoryMock.Setup(x => x.Create(AzureStorageServiceType.Vh)).Returns(AzureStorageServiceMock.Object);
            AudioPlatformServiceMock.Reset();
            AzureStorageServiceMock.Reset();

            AzureStorageServiceMock.Setup(x => x.GetAllBlobNamesByFilePathPrefix(It.IsAny <string>())).ReturnsAsync(new List <string>());


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

            CommandHandlerMock.Verify(c => c.Handle(It.IsAny <CloseConferenceCommand>()), Times.Once);
            AzureStorageServiceMock.Verify(x => x.GetAllBlobNamesByFilePathPrefix(It.IsAny <string>()), Times.Once);

            AudioPlatformServiceMock.Verify(v => v.DeleteAudioApplicationAsync(It.IsAny <Guid>()), Times.Never);
        }