Example #1
0
        public void should_remove_existing_endpoint()
        {
            var displayName = "remove test";
            var sipAddress  = "*****@*****.**";
            var conference  = new ConferenceBuilder().WithEndpoint(displayName, sipAddress).Build();

            var beforeCount = conference.GetEndpoints().Count;

            var endpoint = conference.GetEndpoints().First();

            conference.RemoveEndpoint(endpoint);

            var afterCount = conference.GetEndpoints().Count;

            afterCount.Should().BeLessThan(beforeCount);
        }
Example #2
0
        public void should_throw_exception_when_removing_an_endpoint_that_does_not_exist()
        {
            var displayName = "remove test";
            var sipAddress  = "*****@*****.**";
            var conference  = new ConferenceBuilder().WithEndpoint(displayName, sipAddress).Build();

            var    beforeCount = conference.GetEndpoints().Count;
            var    endpoint    = new Endpoint("Display", "*****@*****.**", "1234", "Defence Sol");
            Action action      = () => conference.RemoveEndpoint(endpoint);

            action.Should().Throw <DomainRuleException>().Where(x =>
                                                                x.ValidationFailures.Any(v => v.Message == "Endpoint does not exist in conference"));

            var afterCount = conference.GetEndpoints().Count;

            beforeCount.Should().Be(afterCount);
        }
Example #3
0
        public void should_add_endpoint()
        {
            var conference  = new ConferenceBuilder().Build();
            var beforeCount = conference.GetEndpoints().Count;
            var endpoint    = new Endpoint("Display", "*****@*****.**", "1234", "Defence Sol");

            conference.AddEndpoint(endpoint);
            var afterCount = conference.GetEndpoints().Count;

            afterCount.Should().BeGreaterThan(beforeCount);

            endpoint.State.Should().Be(EndpointState.NotYetJoined);
            endpoint.DisplayName.Should().Be("Display");
            endpoint.SipAddress.Should().Be("*****@*****.**");
            endpoint.Pin.Should().Be("1234");
            endpoint.DefenceAdvocate.Should().Be("Defence Sol");
        }
        public async Task should_not_update_kinly_when_endpoint_display_name_is_not_updated()
        {
            const string defenceAdvocate = "Sol One";
            var          testEndpoints   = new List <Endpoint>
            {
                new Endpoint("one", "44564", "1234", "Defence Sol"),
                new Endpoint("two", "867744", "5678", "Defence Bol")
            };

            var testConference = new ConferenceBuilder()
                                 .WithParticipant(UserRole.Judge, null)
                                 .WithParticipant(UserRole.Individual, "Applicant", null, null, RoomType.ConsultationRoom)
                                 .WithParticipant(UserRole.Representative, "Applicant")
                                 .WithParticipant(UserRole.Individual, "Respondent")
                                 .WithParticipant(UserRole.Representative, "Respondent")
                                 .WithEndpoints(testEndpoints)
                                 .Build();

            _queryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>
                   (
                       It.Is <GetConferenceByIdQuery>(y => y.ConferenceId == testConference.Id))
                   )
            .ReturnsAsync(testConference);

            _videoPlatformServiceMock
            .Setup(x => x.UpdateVirtualCourtRoomAsync(testConference.Id,
                                                      testConference.AudioRecordingRequired,
                                                      testConference.GetEndpoints()
                                                      .Select(EndpointMapper.MapToEndpoint)))
            .Returns(Task.CompletedTask);

            var response = await _controller.UpdateDisplayNameForEndpointAsync(testConference.Id, "*****@*****.**", new UpdateEndpointRequest
            {
                DefenceAdvocate = defenceAdvocate
            });

            response.Should().NotBeNull();
            response.Should().BeAssignableTo <OkResult>();
            ((OkResult)response).StatusCode.Should().Be((int)HttpStatusCode.OK);

            _commandHandlerMock.Verify(x => x.Handle(It.Is <UpdateEndpointCommand>
                                                     (
                                                         y => y.ConferenceId == testConference.Id && y.SipAddress == "*****@*****.**" && y.DefenceAdvocate == defenceAdvocate
                                                     )), Times.Once);

            _videoPlatformServiceMock.Verify(x => x.UpdateVirtualCourtRoomAsync(testConference.Id,
                                                                                testConference.AudioRecordingRequired,
                                                                                It.IsAny <IEnumerable <EndpointDto> >()), Times.Never);
        }
        public async Task should_return_list_of_endpoints()
        {
            var conference1 = new ConferenceBuilder()
                              .WithEndpoint("Display1", "*****@*****.**")
                              .WithEndpoint("Display2", "*****@*****.**").Build();

            _newConferenceId = conference1.Id;
            await TestDataManager.SeedConference(conference1);

            var query = new GetEndpointsForConferenceQuery(_newConferenceId);

            var result = await _handler.Handle(query);

            result.Should().BeEquivalentTo(conference1.GetEndpoints());
        }
        public async Task Should_remove_endpoint_from_conference()
        {
            var conferenceId  = Guid.NewGuid();
            var testEndpoints = new List <Endpoint>
            {
                new Endpoint("one", "44564", "1234", "Defence Sol"),
                new Endpoint("two", "867744", "5678", "Defence Bol")
            };

            var testConference = new ConferenceBuilder()
                                 .WithParticipant(UserRole.Judge, null)
                                 .WithParticipant(UserRole.Individual, "Applicant", null, null, RoomType.ConsultationRoom)
                                 .WithParticipant(UserRole.Representative, "Applicant")
                                 .WithParticipant(UserRole.Individual, "Respondent")
                                 .WithParticipant(UserRole.Representative, "Respondent")
                                 .WithEndpoints(testEndpoints)
                                 .Build();

            _queryHandlerMock
            .Setup(x => x.Handle <GetConferenceByIdQuery, VideoApi.Domain.Conference>
                   (
                       It.Is <GetConferenceByIdQuery>(y => y.ConferenceId == conferenceId))
                   )
            .ReturnsAsync(testConference);

            _videoPlatformServiceMock
            .Setup(x => x.UpdateVirtualCourtRoomAsync(testConference.Id,
                                                      testConference.AudioRecordingRequired,
                                                      testConference.GetEndpoints()
                                                      .Select(EndpointMapper.MapToEndpoint)))
            .Returns(Task.CompletedTask);

            var response = await _controller.RemoveEndpointFromConference(conferenceId, "*****@*****.**");

            response.Should().NotBeNull();
            response.Should().BeAssignableTo <NoContentResult>();
            ((NoContentResult)response).StatusCode.Should().Be((int)HttpStatusCode.NoContent);

            _commandHandlerMock.Verify(x => x.Handle(It.Is <RemoveEndpointCommand>
                                                     (
                                                         y => y.ConferenceId == conferenceId && y.SipAddress == "*****@*****.**"
                                                     )), Times.Once);

            _videoPlatformServiceMock.Verify(x => x.UpdateVirtualCourtRoomAsync(testConference.Id,
                                                                                testConference.AudioRecordingRequired,
                                                                                It.IsAny <IEnumerable <EndpointDto> >()), Times.Once);
        }