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_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>(); }
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_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); }
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); }
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); }
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 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(); }
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(); }
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); }
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); }
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); }
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); }
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); }
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); }
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); RandomGenerator.Verify(x => x.GetWeakDeterministic(It.IsAny <long>(), It.IsAny <uint>(), It.IsAny <uint>()), Times.Exactly(2)); CommandHandlerMock.Verify(c => c.Handle(It.Is <CreateVideoHearingCommand>(c => c.Endpoints.Count == 1 && c.Endpoints[0].DisplayName == request.Endpoints[0].DisplayName && c.Endpoints[0].Sip == "@WhereAreYou.com")), Times.Once); }
public async Task Should_successfully_book_hearing_without_endpoint() { var newRequest = RequestBuilder.Build(); newRequest.Endpoints = null; var response = await Controller.BookNewHearing(newRequest); 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); RandomGenerator.Verify(x => x.GetWeakDeterministic(It.IsAny <long>(), It.IsAny <uint>(), It.IsAny <uint>()), Times.Never); CommandHandlerMock.Verify(c => c.Handle(It.Is <CreateVideoHearingCommand>(c => c.Endpoints.Count == 0)), Times.Once); }
public async Task Should_return_hearing_details_for_given_hearingid() { var hearingId = Guid.NewGuid(); var hearing = GetHearing("123"); QueryHandlerMock .Setup(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>())) .ReturnsAsync(hearing); var result = await Controller.GetHearingDetailsById(hearingId); result.Should().NotBeNull(); var objectResult = (OkObjectResult)result; objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var hearingDetailsResponse = (HearingDetailsResponse)objectResult.Value; hearingDetailsResponse.Should().NotBeNull(); hearingDetailsResponse.CaseTypeName.Should().Be("Civil Money Claims"); hearingDetailsResponse.HearingTypeName.Should().Be("Application to Set Judgment Aside"); hearingDetailsResponse.Cases.Count.Should().Be(1); QueryHandlerMock.Verify(x => x.Handle <GetHearingByIdQuery, VideoHearing>(It.IsAny <GetHearingByIdQuery>()), Times.Once); }
public async Task Should_Return_An_Empty_List_When_No_Hearing_Is_Returned() { var groupId = Guid.NewGuid(); QueryHandlerMock .Setup(x => x.Handle <GetHearingsByGroupIdQuery, List <VideoHearing> >(It.IsAny <GetHearingsByGroupIdQuery>())) .ReturnsAsync(new List <VideoHearing>()); var result = await Controller.GetHearingsByGroupId(groupId); result.Should().NotBeNull(); var objectResult = (OkObjectResult)result; objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var value = (List <HearingDetailsResponse>)objectResult.Value; value.Count.Should().Be(0); QueryHandlerMock.Verify( x => x.Handle <GetHearingsByGroupIdQuery, List <VideoHearing> >(It.IsAny <GetHearingsByGroupIdQuery>()), Times.Once); }
public async Task Should_Return_List_Of_Hearings_For_GroupId() { var groupId = Guid.NewGuid(); var caseNames = new List <string> { "Case name Day 1 of 2", "Case name Day 2 of 2" }; var hearing1 = GetMultiDayHearing("123", caseNames); var hearing2 = GetMultiDayHearing("123", caseNames); var hearingList = new List <VideoHearing> { hearing1, hearing2 }; QueryHandlerMock .Setup(x => x.Handle <GetHearingsByGroupIdQuery, List <VideoHearing> >(It.IsAny <GetHearingsByGroupIdQuery>())) .ReturnsAsync(hearingList); var result = await Controller.GetHearingsByGroupId(groupId); result.Should().NotBeNull(); var objectResult = (OkObjectResult)result; objectResult.StatusCode.Should().Be((int)HttpStatusCode.OK); var response = (List <HearingDetailsResponse>)objectResult.Value; response.Should().NotBeNull(); response.Count.Should().Be(2); response.First(x => x.Id == hearing1.Id).Should().NotBeNull(); response.First(x => x.Id == hearing2.Id).Should().NotBeNull(); QueryHandlerMock.Verify( x => x.Handle <GetHearingsByGroupIdQuery, List <VideoHearing> >(It.IsAny <GetHearingsByGroupIdQuery>()), Times.Once); }