public async Task Should_be_able_to_save_video_hearing_to_database() { var caseTypeName = "Generic"; var caseType = GetCaseTypeFromDb(caseTypeName); var hearingTypeName = "Automated Test"; var hearingType = caseType.HearingTypes.First(x => x.Name == hearingTypeName); var scheduledDate = DateTime.Today.AddHours(10).AddMinutes(30); var duration = 45; var venue = new RefDataBuilder().HearingVenues.First(); var applicantCaseRole = caseType.CaseRoles.First(x => x.Name == "Applicant"); var applicantRepresentativeHearingRole = applicantCaseRole.HearingRoles.First(x => x.Name == "Representative"); var judgeCaseRole = caseType.CaseRoles.First(x => x.Name == "Judge"); var judgeHearingRole = judgeCaseRole.HearingRoles.First(x => x.Name == "Judge"); var newPerson = new PersonBuilder(true).Build(); var newJudgePerson = new PersonBuilder(true).Build(); var newParticipant = new NewParticipant() { Person = newPerson, CaseRole = applicantCaseRole, HearingRole = applicantRepresentativeHearingRole, DisplayName = $"{newPerson.FirstName} {newPerson.LastName}", Representee = string.Empty }; var newJudgeParticipant = new NewParticipant() { Person = newJudgePerson, CaseRole = judgeCaseRole, HearingRole = judgeHearingRole, DisplayName = $"{newJudgePerson.FirstName} {newJudgePerson.LastName}", Representee = string.Empty }; var participants = new List <NewParticipant>() { newParticipant, newJudgeParticipant }; var cases = new List <Case> { new Case("01234567890", "Test Add") }; var hearingRoomName = "Room01"; var otherInformation = "OtherInformation01"; var createdBy = "User01"; const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var endpoints = new List <NewEndpoint> { new NewEndpoint { DisplayName = "display 1", Sip = Guid.NewGuid().ToString(), Pin = "1234", DefenceAdvocateUsername = null }, new NewEndpoint { DisplayName = "display 2", Sip = Guid.NewGuid().ToString(), Pin = "5678", DefenceAdvocateUsername = null } }; var linkedParticipants = new List <LinkedParticipantDto> { new LinkedParticipantDto( newParticipant.Person.ContactEmail, newJudgeParticipant.Person.ContactEmail, LinkedParticipantType.Interpreter) }; var command = new CreateVideoHearingCommand(caseType, hearingType, scheduledDate, duration, venue, participants, cases, questionnaireNotRequired, audioRecordingRequired, endpoints, linkedParticipants) { HearingRoomName = hearingRoomName, OtherInformation = otherInformation, CreatedBy = createdBy }; await _commandHandler.Handle(command); command.NewHearingId.Should().NotBeEmpty(); _newHearingId = command.NewHearingId; Hooks.AddHearingForCleanup(_newHearingId); var returnedVideoHearing = await _queryHandler.Handle(new GetHearingByIdQuery(_newHearingId)); returnedVideoHearing.Should().NotBeNull(); returnedVideoHearing.CaseType.Should().NotBeNull(); returnedVideoHearing.HearingVenue.Should().NotBeNull(); returnedVideoHearing.HearingType.Should().NotBeNull(); var participantsFromDb = returnedVideoHearing.GetParticipants(); participantsFromDb.Any().Should().BeTrue(); returnedVideoHearing.GetCases().Any().Should().BeTrue(); returnedVideoHearing.GetEndpoints().Any().Should().BeTrue(); var linkedParticipantsFromDb = participantsFromDb.SelectMany(x => x.LinkedParticipants).ToList(); linkedParticipantsFromDb.Should().NotBeEmpty(); foreach (var linkedParticipant in linkedParticipantsFromDb) { linkedParticipant.Type.Should().BeAssignableTo <LinkedParticipantType>(); linkedParticipant.Type.Should().Be(LinkedParticipantType.Interpreter); participantsFromDb.Any(x => x.Id == linkedParticipant.LinkedId).Should().BeTrue(); participantsFromDb.Any(x => x.Id == linkedParticipant.ParticipantId).Should().BeTrue(); } }
public async Task Should_be_able_to_save_video_hearing_to_database() { var caseTypeName = "Civil Money Claims"; var caseType = GetCaseTypeFromDb(caseTypeName); var hearingTypeName = "Application to Set Judgment Aside"; var hearingType = caseType.HearingTypes.First(x => x.Name == hearingTypeName); var scheduledDate = DateTime.Today.AddHours(10).AddMinutes(30); var duration = 45; var venue = new RefDataBuilder().HearingVenues.First(); var claimantCaseRole = caseType.CaseRoles.First(x => x.Name == "Claimant"); var claimantRepresentativeHearingRole = claimantCaseRole.HearingRoles.First(x => x.Name == "Representative"); var judgeCaseRole = caseType.CaseRoles.First(x => x.Name == "Judge"); var judgeHearingRole = judgeCaseRole.HearingRoles.First(x => x.Name == "Judge"); var newPerson = new PersonBuilder(true).Build(); var newJudgePerson = new PersonBuilder(true).Build(); var newParticipant = new NewParticipant() { Person = newPerson, CaseRole = claimantCaseRole, HearingRole = claimantRepresentativeHearingRole, DisplayName = $"{newPerson.FirstName} {newPerson.LastName}", Reference = string.Empty, Representee = string.Empty }; var newJudgeParticipant = new NewParticipant() { Person = newJudgePerson, CaseRole = judgeCaseRole, HearingRole = judgeHearingRole, DisplayName = $"{newJudgePerson.FirstName} {newJudgePerson.LastName}", Reference = string.Empty, Representee = string.Empty }; var participants = new List <NewParticipant>() { newParticipant, newJudgeParticipant }; var cases = new List <Case> { new Case("01234567890", "Test Add") }; var hearingRoomName = "Room01"; var otherInformation = "OtherInformation01"; var createdBy = "User01"; const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var command = new CreateVideoHearingCommand(caseType, hearingType, scheduledDate, duration, venue, participants, cases, questionnaireNotRequired, audioRecordingRequired) { HearingRoomName = hearingRoomName, OtherInformation = otherInformation, CreatedBy = createdBy }; await _commandHandler.Handle(command); command.NewHearingId.Should().NotBeEmpty(); _newHearingId = command.NewHearingId; var returnedVideoHearing = await _queryHandler.Handle(new GetHearingByIdQuery(_newHearingId)); returnedVideoHearing.Should().NotBeNull(); returnedVideoHearing.CaseType.Should().NotBeNull(); returnedVideoHearing.HearingVenue.Should().NotBeNull(); returnedVideoHearing.HearingType.Should().NotBeNull(); returnedVideoHearing.GetParticipants().Any().Should().BeTrue(); returnedVideoHearing.GetCases().Any().Should().BeTrue(); }