public async Task Should_retrieve_all_messages_for_the_participant() { var conference = new ConferenceBuilder(true) .WithParticipant(UserRole.Individual, "Claimant") .WithParticipant(UserRole.Judge, "Judge") .Build(); var judge = conference.GetParticipants().First(x => x.UserRole == UserRole.Judge); var participant = conference.GetParticipants().First(x => x.UserRole == UserRole.Individual); var vhOfficer = "VH Officer"; conference.AddInstantMessage(vhOfficer, "InstantMessage 1", judge.DisplayName); conference.AddInstantMessage(judge.DisplayName, "InstantMessage 2", vhOfficer); conference.AddInstantMessage(participant.Username, "Hello VHO", vhOfficer); conference.AddInstantMessage(vhOfficer, "Hello ParticipantOne", participant.Username); var seededConference = await TestDataManager.SeedConference(conference); _newConferenceId = seededConference.Id; var query = new GetInstantMessagesForConferenceQuery(_newConferenceId, participant.Username); var results = await _handler.Handle(query); results.Count.Should().Be(conference.GetInstantMessageHistoryFor(participant.Username).Count); results.Should().BeInDescendingOrder(x => x.TimeStamp); }
public void Should_add_new_participant_to_hearing() { var conference = new ConferenceBuilder().Build(); var beforeCount = conference.GetParticipants().Count; var participant = new ParticipantBuilder().Build(); conference.AddParticipant(participant); var afterCount = conference.GetParticipants().Count; afterCount.Should().BeGreaterThan(beforeCount); }
public void Should_remove_participant_from_hearing() { var conference = new ConferenceBuilder() .WithParticipant(UserRole.Individual, "Applicant") .Build(); var beforeCount = conference.GetParticipants().Count; var participant = conference.GetParticipants().First(); conference.RemoveParticipant(participant); var afterCount = conference.GetParticipants().Count; afterCount.Should().BeLessThan(beforeCount); }
public void Should_map_all_properties() { var conference = new ConferenceBuilder() .WithConferenceStatus(ConferenceState.InSession) .WithConferenceStatus(ConferenceState.Paused) .WithConferenceStatus(ConferenceState.Closed) .WithMeetingRoom("https://poc.node.com", "*****@*****.**") .WithParticipants(3) .WithMessages(5) .WithInterpreterRoom() .Build(); var pexipSelfTestNode = "*****@*****.**"; var response = ConferenceToDetailsResponseMapper.MapConferenceToResponse(conference, pexipSelfTestNode); response.Should().BeEquivalentTo(conference, options => options .Excluding(x => x.HearingRefId) .Excluding(x => x.Participants) .Excluding(x => x.ConferenceStatuses) .Excluding(x => x.State) .Excluding(x => x.InstantMessageHistory) .Excluding(x => ExcludeIdFromMessage(x)) .Excluding(x => x.IngestUrl) .Excluding(x => x.ActualStartTime) .Excluding(x => x.Endpoints) .Excluding(x => x.CreatedDateTime) .Excluding(x => x.Rooms) ); response.StartedDateTime.Should().HaveValue().And.Be(conference.ActualStartTime); response.ClosedDateTime.Should().HaveValue().And.Be(conference.ClosedDateTime); response.CurrentStatus.Should().BeEquivalentTo(conference.GetCurrentStatus()); var participants = conference.GetParticipants(); response.Participants.Should().BeEquivalentTo(participants, options => options .Excluding(x => x.ParticipantRefId) .Excluding(x => x.TestCallResultId) .Excluding(x => x.TestCallResult) .Excluding(x => x.CurrentConsultationRoomId) .Excluding(x => x.CurrentConsultationRoom) .Excluding(x => x.CurrentRoom) .Excluding(x => x.State) .Excluding(x => x.LinkedParticipants) .Excluding(x => x.RoomParticipants) ); var civilianRoom = response.CivilianRooms.First(); var room = conference.Rooms.First(); civilianRoom.Id.Should().Be(room.Id); civilianRoom.Label.Should().Be(room.Label); civilianRoom.Participants.Select(x => x).Should() .BeEquivalentTo(room.RoomParticipants.Select(x => x.ParticipantId)); }
public void Should_not_add_existing_participant_to_hearing() { var conference = new ConferenceBuilder() .WithParticipant(UserRole.Individual, "Claimant") .WithParticipant(UserRole.Representative, "Claimant") .WithParticipant(UserRole.Representative, "Defendant") .WithParticipant(UserRole.Individual, "Defendant") .Build(); var beforeCount = conference.GetParticipants().Count; var participant = conference.GetParticipants().First(); Action action = () => conference.AddParticipant(participant); action.Should().Throw <DomainRuleException>(); var afterCount = conference.GetParticipants().Count; afterCount.Should().Be(beforeCount); }
public void Should_not_fail_when_removing_non_existent_participant() { var conference = new ConferenceBuilder() .WithParticipant(UserRole.Individual, "Applicant") .Build(); var beforeCount = conference.GetParticipants().Count; var userRole = UserRole.Representative; var caseGroup = "Applicant"; var hearingRole = ParticipantBuilder.DetermineHearingRole(userRole, caseGroup); var participant = Builder <Participant> .CreateNew().WithFactory(() => new Participant(Guid.NewGuid(), Name.FullName(), Name.First(), Name.Last(), Name.FullName(), $"{RandomNumber.Next()}@hmcts.net", userRole, hearingRole, caseGroup, $"{RandomNumber.Next()}@hmcts.net", Phone.Number())).Build(); Action action = () => conference.RemoveParticipant(participant); action.Should().Throw <DomainRuleException>(); var afterCount = conference.GetParticipants().Count; afterCount.Should().Be(beforeCount); }
public void Should_add_conference_status() { var conference = new ConferenceBuilder() .WithParticipant(UserRole.Individual, "Claimant") .Build(); conference.GetCurrentStatus().Should().Be(ConferenceState.NotStarted); var beforeCount = conference.GetConferenceStatuses().Count; conference.CloseConference(); var afterCount = conference.GetParticipants().Count; afterCount.Should().BeGreaterThan(beforeCount); conference.GetCurrentStatus().Should().Be(ConferenceState.Closed); }
public async Task Should_not_remove_heartbeats_for_conferences_within_14_days() { _conferenceList = new List <Conference>(); var utcDate = DateTime.UtcNow; var hearingWithin14Days = utcDate.AddDays(-13); var conference1 = new ConferenceBuilder(true, scheduledDateTime: hearingWithin14Days) .WithParticipant(UserRole.Representative, "Respondent") .WithParticipant(UserRole.Judge, null) .WithConferenceStatus(ConferenceState.Closed) .Build(); _conference1Id = conference1.Id; var participantId = conference1.GetParticipants().First().Id; _conferenceList.Add(conference1); foreach (var c in _conferenceList) { await TestDataManager.SeedConference(c); } var command = new SaveHeartbeatCommand(_conference1Id, participantId, 0.00M, 0.00M, 0.40M, 0.10M, 0.00M, 0.00M, 0.50M, 0.20M, DateTime.UtcNow, "Chrome", "84.0.4147.105", "Mac OS X", "10.15.7"); await _saveHeartbeatHandler.Handle(command); command = new SaveHeartbeatCommand(_conference1Id, participantId, 0.00M, 0.00M, 0.50M, 1.50M, 0.00M, 0.00M, 0.50M, 1.50M, DateTime.UtcNow, "Chrome", "84.0.4147.105", "Mac OS X", "10.15.7"); await _saveHeartbeatHandler.Handle(command); command = new SaveHeartbeatCommand(_conference1Id, participantId, 0.30M, 0.15M, 0.60M, 1.50M, 0.00M, 0.00M, 0.80M, 1.50M, DateTime.UtcNow, "Chrome", "84.0.4147.105", "Mac OS X", "10.15.7"); await _saveHeartbeatHandler.Handle(command); var removeCommand = new RemoveHeartbeatsForConferencesCommand(); await _handler.Handle(removeCommand); List <Heartbeat> heartbeats; await using (var db = new VideoApiDbContext(VideoBookingsDbContextOptions)) { heartbeats = await db.Heartbeats.Where(x => x.ConferenceId == _conference1Id).ToListAsync(); } var afterCount = heartbeats.Count; afterCount.Should().Be(3); }
public void Should_map_all_properties() { var conference = new ConferenceBuilder() .WithConferenceStatus(ConferenceState.InSession) .WithConferenceStatus(ConferenceState.Paused) .WithConferenceStatus(ConferenceState.Closed) .WithMeetingRoom("https://poc.node.com", "*****@*****.**") .WithParticipants(3) .WithMessages(5) .Build(); var pexipSelfTestNode = "*****@*****.**"; var response = ConferenceToDetailsResponseMapper.MapConferenceToResponse(conference, pexipSelfTestNode); response.Should().BeEquivalentTo(conference, options => options .Excluding(x => x.HearingRefId) .Excluding(x => x.Participants) .Excluding(x => x.ConferenceStatuses) .Excluding(x => x.State) .Excluding(x => x.InstantMessageHistory) .Excluding(x => ExcludeIdFromMessage(x)) .Excluding(x => x.IngestUrl) .Excluding(x => x.ActualStartTime) .Excluding(x => x.Endpoints) ); response.StartedDateTime.Should().HaveValue().And.Be(conference.ActualStartTime); response.ClosedDateTime.Should().HaveValue().And.Be(conference.ClosedDateTime); response.CurrentStatus.Should().BeEquivalentTo(conference.GetCurrentStatus()); var participants = conference.GetParticipants(); response.Participants.Should().BeEquivalentTo(participants, options => options .Excluding(x => x.ParticipantRefId) .Excluding(x => x.TestCallResultId) .Excluding(x => x.TestCallResult) .Excluding(x => x.CurrentRoom) .Excluding(x => x.State) ); }
public async Task <Conference> SeedConference() { var conference = new ConferenceBuilder(true) .WithParticipant(UserRole.Individual, "Claimant") .WithParticipant(UserRole.Representative, "Claimant") .WithParticipant(UserRole.Individual, "Defendant") .WithParticipant(UserRole.Representative, "Defendant") .WithParticipant(UserRole.Judge, null) .WithConferenceStatus(ConferenceState.InSession) .WithMeetingRoom(_services.PexipNode, _services.ConferenceUsername) .WithAudioRecordingRequired(false) .Build(); var conferenceType = typeof(Conference); conferenceType.GetProperty("ActualStartTime")?.SetValue(conference, conference.ScheduledDateTime.AddMinutes(1)); foreach (var individual in conference.GetParticipants().Where(x => x.UserRole == UserRole.Individual)) { individual.UpdateTestCallResult(true, TestScore.Okay); } return(await SeedConference(conference)); }