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_Ok() { var request = RequestBuilder(); ConsultationServiceMock.Setup(x => x.GetAvailableConsultationRoomAsync(request.ConferenceId, request.RoomType.MapToDomainEnum())) .ReturnsAsync(_testConsultationRoom); ConsultationServiceMock.Setup(x => x.ParticipantTransferToRoomAsync(request.ConferenceId, request.RequestedBy, _testConsultationRoom.Label)); var result = await Controller.StartConsultationRequestAsync(request); result.Should().BeOfType <AcceptedResult>(); }
public async Task Should_Throw_NotFoundException_When_Conference_Does_Not_Exist() { var request = RequestBuilder(); request.ConferenceId = Guid.NewGuid(); ConsultationServiceMock.Setup(x => x.GetAvailableConsultationRoomAsync(request.ConferenceId, request.RoomType.MapToDomainEnum())) .ThrowsAsync(new ConferenceNotFoundException(request.ConferenceId)); var result = await Controller.StartConsultationRequestAsync(request); var actionResult = result.As <NotFoundObjectResult>(); actionResult.Should().NotBeNull(); }
public async Task Should_Start_New_Consultation_Returns_Ok() { var request = RequestBuilder(); ConsultationServiceMock.Setup(x => x.CreateNewConsultationRoomAsync(request.ConferenceId, It.IsAny <VideoApi.Domain.Enums.VirtualCourtRoomType>(), It.IsAny <bool>())).ReturnsAsync(_testConsultationRoom); ConsultationServiceMock.Setup(x => x.ParticipantTransferToRoomAsync(request.ConferenceId, request.RequestedBy, _testConsultationRoom.Label)); var result = await Controller.StartNewConsultationRequestAsync(request); result.Should().BeOfType <OkObjectResult>(); }
public async Task Should_Start_New_Consultation_Returns_BadRequest_for_kinly_exeption() { var request = RequestBuilder(); ConsultationServiceMock.Setup(x => x.CreateNewConsultationRoomAsync(request.ConferenceId, It.IsAny <VideoApi.Domain.Enums.VirtualCourtRoomType>(), It.IsAny <bool>())) .ThrowsAsync(new KinlyApiException("Error", 400, "Response", null, null)); ConsultationServiceMock.Setup(x => x.ParticipantTransferToRoomAsync(request.ConferenceId, request.RequestedBy, _testConsultationRoom.Label)); var result = await Controller.StartNewConsultationRequestAsync(request); result.Should().BeOfType <BadRequestObjectResult>(); }
public async Task Should_Return_NotFound_When_Participant_Cannot_Be_Found() { var request = RequestBuilder(); request.RequestedBy = Guid.NewGuid(); ConsultationServiceMock.Setup(x => x.GetAvailableConsultationRoomAsync(request.ConferenceId, request.RoomType.MapToDomainEnum())) .ReturnsAsync(_testConsultationRoom); ConsultationServiceMock.Setup(x => x.ParticipantTransferToRoomAsync(request.ConferenceId, request.RequestedBy, _testConsultationRoom.Label)) .ThrowsAsync(new ParticipantNotFoundException(request.RequestedBy)); var result = await Controller.StartConsultationRequestAsync(request); var actionResult = result.As <NotFoundObjectResult>(); actionResult.Should().NotBeNull(); }
public async Task Should_Return_BadRequest_When_Participant_Cannot_Be_Found() { var request = RequestBuilder(); var kinlyApiException = new KinlyApiException("", (int)HttpStatusCode.BadRequest, "payload", new Dictionary <string, IEnumerable <string> >(), new Exception()); ConsultationServiceMock.Setup(x => x.GetAvailableConsultationRoomAsync(request.ConferenceId, request.RoomType.MapToDomainEnum())) .ReturnsAsync(_testConsultationRoom); ConsultationServiceMock .Setup(x => x.ParticipantTransferToRoomAsync(request.ConferenceId, request.RequestedBy, _testConsultationRoom.Label)) .ThrowsAsync(kinlyApiException); var result = await Controller.StartConsultationRequestAsync(request); var actionResult = result.As <BadRequestObjectResult>(); actionResult.Should().NotBeNull(); }