示例#1
0
        public void Should_throw_exception_when_validation_fails()
        {
            var hearing = new VideoHearingBuilder().Build();

            hearing.AddCase("0875", "Test Case Add", false);
            var          beforeUpdatedDate        = hearing.UpdatedDate;
            HearingVenue newVenue                 = null;
            var          newDateTime              = DateTime.Today.AddDays(-10);
            var          newDuration              = -10;
            var          updatedBy                = "testuser";
            var          cases                    = new List <Case>();
            const bool   questionnaireNotRequired = false;
            const bool   audioRecordingRequired   = true;

            Action action = () => hearing.UpdateHearingDetails(newVenue, newDateTime, newDuration,
                                                               string.Empty, string.Empty, updatedBy, cases, questionnaireNotRequired, audioRecordingRequired);

            action.Should().Throw <DomainRuleException>()
            .And.ValidationFailures.Should()
            .Contain(x => x.Name == "ScheduledDuration")
            .And.Contain(x => x.Name == "ScheduledDateTime")
            .And.Contain(x => x.Name == "Venue");

            hearing.UpdatedDate.Should().Be(beforeUpdatedDate);
        }
        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);
        }
示例#3
0
 public CreateVideoHearingCommand(CaseType caseType, HearingType hearingType, DateTime scheduledDateTime,
                                  int scheduledDuration, HearingVenue venue, List <NewParticipant> participants, List <Case> cases,
                                  bool questionnaireNotRequired, bool audioRecordingRequired)
 {
     CaseType                 = caseType;
     HearingType              = hearingType;
     ScheduledDateTime        = scheduledDateTime;
     ScheduledDuration        = scheduledDuration;
     Venue                    = venue;
     Participants             = participants;
     Cases                    = cases;
     QuestionnaireNotRequired = questionnaireNotRequired;
     AudioRecordingRequired   = audioRecordingRequired;
 }
 public UpdateHearingCommand(Guid hearingId, DateTime scheduledDateTime, int scheduledDuration,
                             HearingVenue hearingVenue, string hearingRoomName, string otherInformation, string updatedBy,
                             List <Case> cases, bool questionnaireNotRequired, bool audioRecordingRequired)
 {
     HearingId                = hearingId;
     ScheduledDateTime        = scheduledDateTime;
     ScheduledDuration        = scheduledDuration;
     HearingVenue             = hearingVenue;
     HearingRoomName          = hearingRoomName;
     OtherInformation         = otherInformation;
     UpdatedBy                = updatedBy;
     Cases                    = cases;
     QuestionnaireNotRequired = questionnaireNotRequired;
     AudioRecordingRequired   = audioRecordingRequired;
 }
        public static CreateVideoHearingCommand Map(
            BookNewHearingRequest request,
            CaseType caseType,
            HearingType hearingType,
            HearingVenue venue,
            List <Case> cases,
            IRandomGenerator randomGenerator,
            string sipAddressStem)
        {
            var newParticipants    = MapParticipants(request, caseType);
            var newEndpoints       = MapEndpoints(request, randomGenerator, sipAddressStem);
            var linkedParticipants = MapLinkedParticipants(request);

            return(new CreateVideoHearingCommand(caseType, hearingType,
                                                 request.ScheduledDateTime, request.ScheduledDuration, venue, newParticipants, cases,
                                                 request.QuestionnaireNotRequired, request.AudioRecordingRequired, newEndpoints, linkedParticipants)
            {
                HearingRoomName = request.HearingRoomName,
                OtherInformation = request.OtherInformation,
                CreatedBy = request.CreatedBy
            });
        }