Esempio n. 1
0
        public async Task Should_Create_New_ConsultationRoom()
        {
            var mockCommand = new CreateConsultationRoomCommand(_request.ConferenceId, "Judge", _request.RoomType.MapToDomainEnum(), false);

            _commandHandler.Setup(x => x.Handle(mockCommand));
            var consultationRoomParams = new CreateConsultationRoomParams
            {
                Room_label_prefix = _request.RoomType.ToString()
            };

            _kinlyApiClient
            .Setup(x => x.CreateConsultationRoomAsync(It.IsAny <string>(), It.IsAny <CreateConsultationRoomParams>()))
            .ReturnsAsync(new CreateConsultationRoomResponse()
            {
                Room_label = "Label"
            });

            var returnedRoom =
                await _consultationService.CreateNewConsultationRoomAsync(_request.ConferenceId, _request.RoomType.MapToDomainEnum());

            _kinlyApiClient.Verify(x => x.CreateConsultationRoomAsync(It.Is <string>(
                                                                          y => y.Equals(_request.ConferenceId.ToString())), It.Is <CreateConsultationRoomParams>(
                                                                          y => y.Room_label_prefix.Equals(consultationRoomParams.Room_label_prefix))), Times.Once);
            returnedRoom.Should().BeOfType <ConsultationRoom>();
            returnedRoom.Should().NotBeNull();
        }
Esempio n. 2
0
        public async Task <ConsultationRoom> GetAvailableConsultationRoomAsync(Guid conferenceId, VirtualCourtRoomType roomType)
        {
            var query       = new GetAvailableConsultationRoomsByRoomTypeQuery(roomType, conferenceId);
            var listOfRooms = await _queryHandler.Handle <GetAvailableConsultationRoomsByRoomTypeQuery, List <ConsultationRoom> >(query);

            var room = listOfRooms?.FirstOrDefault(x => x.Type.Equals(roomType));

            if (room == null)
            {
                var consultationRoomParams = new CreateConsultationRoomParams
                {
                    Room_label_prefix = roomType.ToString()
                };
                var createConsultationRoomResponse =
                    await CreateConsultationRoomAsync(conferenceId.ToString(),
                                                      consultationRoomParams);

                var createRoomCommand = new CreateConsultationRoomCommand(conferenceId,
                                                                          createConsultationRoomResponse.Room_label,
                                                                          roomType,
                                                                          false);
                await _commandHandler.Handle(createRoomCommand);

                room = new ConsultationRoom(conferenceId, createConsultationRoomResponse.Room_label, roomType, false);
            }

            return(room);
        }
Esempio n. 3
0
        public async Task <ConsultationRoom> CreateNewConsultationRoomAsync(Guid conferenceId, VirtualCourtRoomType roomType = VirtualCourtRoomType.Participant, bool locked = false)
        {
            var consultationRoomParams = new CreateConsultationRoomParams
            {
                Room_label_prefix = roomType.ToString()
            };
            var createConsultationRoomResponse = await CreateConsultationRoomAsync(conferenceId.ToString(), consultationRoomParams);

            var createRoomCommand = new CreateConsultationRoomCommand(conferenceId, createConsultationRoomResponse.Room_label, roomType, locked);
            await _commandHandler.Handle(createRoomCommand);

            var room = new ConsultationRoom(conferenceId, createConsultationRoomResponse.Room_label, roomType, locked);

            return(room);
        }
        public async Task Should_save_new_room()
        {
            var seededConference = await TestDataManager.SeedConference();

            TestContext.WriteLine($"New seeded conference id: {seededConference.Id}");
            _newConferenceId = seededConference.Id;


            var command = new CreateConsultationRoomCommand(_newConferenceId, "Room1", VirtualCourtRoomType.JudgeJOH, false);

            await _handler.Handle(command);

            command.NewRoomId.Should().BeGreaterThan(0);
            command.ConferenceId.Should().Be(_newConferenceId);
            command.Type.Should().Be(VirtualCourtRoomType.JudgeJOH);
        }
Esempio n. 5
0
        public async Task Should_Return_A_Valid_ConsultationRoom_With_A_Valid_Request()
        {
            _queryHandler.Setup(x => x.Handle <GetAvailableConsultationRoomsByRoomTypeQuery, List <ConsultationRoom> >(
                                    It.Is <GetAvailableConsultationRoomsByRoomTypeQuery>(
                                        query => query.ConferenceId.Equals(_request.ConferenceId) &&
                                        query.CourtRoomType.Equals(_request.RoomType.MapToDomainEnum())))).ReturnsAsync(_rooms);

            var mockCommand = new CreateConsultationRoomCommand(_request.ConferenceId, "Judge", _request.RoomType.MapToDomainEnum(), false);

            _commandHandler.Setup(x => x.Handle(mockCommand));

            var returnedRoom =
                await _consultationService.GetAvailableConsultationRoomAsync(_request.ConferenceId, _request.RoomType.MapToDomainEnum());

            returnedRoom.Should().BeOfType <ConsultationRoom>();
            returnedRoom.Should().NotBeNull();
        }
        public void Should_throw_exception_if_no_conference_found()
        {
            var command = new CreateConsultationRoomCommand(Guid.NewGuid(), "Room1", VirtualCourtRoomType.JudgeJOH, false);

            Assert.ThrowsAsync <ConferenceNotFoundException>(() => _handler.Handle(command));
        }