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); }
protected static VideoHearing GetHearing(string caseNumber) { var hearing = new VideoHearingBuilder().Build(); if (!caseNumber.IsNullOrEmpty()) { hearing.AddCase(caseNumber, "Case name", true); } foreach (var participant in hearing.Participants) { participant.HearingRole = new HearingRole(1, "Name") { UserRole = new UserRole(1, "User"), }; participant.CaseRole = new CaseRole(1, "Name"); } hearing.AddEndpoints(new List <Endpoint> { new Endpoint("new endpoint", Guid.NewGuid().ToString(), "pin", null) }); return(hearing); }
public void Should_publish_message_to_queue_when_ParticipantsAddedIntegrationEvent_is_raised() { var hearing = new VideoHearingBuilder().Build(); hearing.CaseType = new CaseType(1, "test"); hearing.AddCase("1234", "test", true); var individuals = hearing.GetParticipants().Where(x => x is Individual).ToList(); var individual1 = individuals.First(); individual1.HearingRole = new HearingRole(1, "Litigant in person") { UserRole = new UserRole(1, "Individual") }; individual1.CaseRole = new CaseRole(1, "test"); var participantAddedIntegrationEvent = new ParticipantsAddedIntegrationEvent(hearing.Id, new List <Participant> { individual1 }); _eventPublisher.PublishAsync(participantAddedIntegrationEvent); _serviceBusQueueClient.Count.Should().Be(1); var @event = _serviceBusQueueClient.ReadMessageFromQueue(); @event.IntegrationEvent.Should().BeOfType <ParticipantsAddedIntegrationEvent>(); }
public void Should_update_hearing_details() { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("0875", "Test Case Add", false); var beforeUpdatedDate = hearing.UpdatedDate; var newVenue = new RefDataBuilder().HearingVenues.Last(); var newDateTime = DateTime.Today.AddDays(10).AddHours(14); var newDuration = 150; var hearingRoomName = "Room03 Edit"; var otherInformation = "OtherInformation03 Edit"; var updatedBy = "testuser"; var caseName = "CaseName Update"; var caseNumber = "CaseNumber Update"; const bool questionnaireNotRequired = false; const bool audioRecordingRequired = true; var casesToUpdate = new List <Case> { new Case(caseNumber, caseName) }; hearing.UpdateHearingDetails(newVenue, newDateTime, newDuration, hearingRoomName, otherInformation, updatedBy, casesToUpdate, questionnaireNotRequired, audioRecordingRequired); hearing.UpdatedDate.Should().BeAfter(beforeUpdatedDate); var updatedCases = hearing.GetCases(); updatedCases.First().Name.Should().Be(caseName); updatedCases.First().Number.Should().Be(caseNumber); }
private VideoHearing MockHearingWithCase() { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("234", "X vs Y", true); return(hearing); }
public void Should_not_add_existing_case() { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("0875", "Test Case Add", false); var beforeAddCount = hearing.GetCases().Count; Action action = () => hearing.AddCase("0875", "Test Case Add", false); action.Should().Throw <DomainRuleException>().And.ValidationFailures .Any(x => x.Message == "Case already exists for the hearing").Should().BeTrue(); var afterAddCount = hearing.GetCases().Count; afterAddCount.Should().Be(beforeAddCount); }
private List <VideoHearing> CreateListOfVideoHearings(Guid personId, string firstName, string lastName, string username) { var hearing1 = new VideoHearingBuilder().WithCase().Build(); var hearing2 = new VideoHearingBuilder().WithCase().Build(); var hearing3 = new VideoHearingBuilder().WithCase().Build(); var hearing4 = new VideoHearingBuilder().WithCase().Build(); var hearing5 = new VideoHearingBuilder().WithCase().Build(); var person1 = hearing1.GetPersons().First(); var participant1 = hearing1.GetParticipants().First(x => x.Person == person1); person1.UpdatePerson(firstName, lastName, username); person1.SetProtected(nameof(person1.Id), personId); participant1.SetProtected(nameof(participant1.PersonId), personId); var person2 = hearing2.GetPersons().First(); var participant2 = hearing2.GetParticipants().First(x => x.Person == person2); person2.UpdatePerson(firstName, lastName, username); person2.SetProtected(nameof(person2.Id), personId); participant2.SetProtected(nameof(participant2.PersonId), personId); var person3 = hearing3.GetPersons().First(); var participant3 = hearing3.GetParticipants().First(x => x.Person == person3); person3.UpdatePerson(firstName, lastName, username); person3.SetProtected(nameof(person3.Id), personId); participant3.SetProtected(nameof(participant3.PersonId), personId); var person4 = hearing4.GetPersons().First(); var participant4 = hearing4.GetParticipants().First(x => x.Person == person4); person4.UpdatePerson(firstName, lastName, username); person4.SetProtected(nameof(person4.Id), personId); participant4.SetProtected(nameof(participant4.PersonId), personId); var person5 = hearing5.GetPersons().First(); var participant5 = hearing5.GetParticipants().First(x => x.Person == person5); person5.UpdatePerson(firstName, lastName, username); person5.SetProtected(nameof(person5.Id), personId); participant5.SetProtected(nameof(participant5.PersonId), personId); participant5.DisplayName = "*****@*****.**"; hearing2.UpdateStatus(BookingStatus.Created, "test", null); hearing3.UpdateStatus(BookingStatus.Created, "test", null); hearing3.UpdateStatus(BookingStatus.Failed, "test", null); hearing4.UpdateStatus(BookingStatus.Cancelled, "test", "test cancellation"); hearing5.UpdateStatus(BookingStatus.Created, "test", null); hearing5.AddCase("FUHSTD", "*****@*****.**", false); return(new List <VideoHearing> { hearing1, hearing2, hearing3, hearing4, hearing5 }); }
public void Should_add_new_case() { var hearing = new VideoHearingBuilder().Build(); var beforeAddCount = hearing.GetCases().Count; hearing.AddCase("0875", "Test Case Add", false); var afterAddCount = hearing.GetCases().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
private static VideoHearing GetHearing(bool addCase) { var hearing = new VideoHearingBuilder().Build(); if (addCase) { hearing.AddCase("Test 001 ", "Case name", true); } return(hearing); }
public void Should_publish_message_to_queue_when_HearingIsReadyForVideoIntegrationEvent_is_raised() { var hearing = new VideoHearingBuilder().Build(); hearing.CaseType = new CaseType(1, "test"); hearing.AddCase("1234", "test", true); var individuals = hearing.GetParticipants().Where(x => x is Individual).ToList(); var individual1 = individuals.First(); individual1.HearingRole = new HearingRole(1, "Claimant LIP") { UserRole = new UserRole(1, "Individual") }; individual1.CaseRole = new CaseRole(1, "test"); var individual2 = individuals.Last(); individual2.HearingRole = new HearingRole(2, "Defendant LIP") { UserRole = new UserRole(1, "Individual") }; individual2.CaseRole = new CaseRole(2, "test2"); var representative = hearing.GetParticipants().Single(x => x is Representative); representative.HearingRole = new HearingRole(5, "Representative") { UserRole = new UserRole(2, "Representative") }; representative.CaseRole = new CaseRole(3, "test3"); var judge = hearing.GetParticipants().Single(x => x is Judge); judge.HearingRole = new HearingRole(5, "Judge") { UserRole = new UserRole(2, "Judge") }; judge.CaseRole = new CaseRole(3, "test4"); var hearingIsReadyForVideoIntegrationEvent = new HearingIsReadyForVideoIntegrationEvent(hearing); _eventPublisher.PublishAsync(hearingIsReadyForVideoIntegrationEvent); _serviceBusQueueClient.Count.Should().Be(1); var @event = _serviceBusQueueClient.ReadMessageFromQueue(); @event.IntegrationEvent.Should().BeOfType <HearingIsReadyForVideoIntegrationEvent>(); var typedEvent = (HearingIsReadyForVideoIntegrationEvent)@event.IntegrationEvent; typedEvent.Hearing.RecordAudio.Should().Be(hearing.AudioRecordingRequired); typedEvent.Participants.Count.Should().Be(hearing.GetParticipants().Count); }
public void Should_publish_message_to_queue_when_HearingIsReadyForVideoIntegrationEvent_is_raised() { var hearing = new VideoHearingBuilder().Build(); hearing.CaseType = new CaseType(1, "test"); hearing.AddCase("1234", "test", true); var individuals = hearing.GetParticipants().Where(x => x is Individual).ToList(); var individual1 = individuals.First(); individual1.CaseRole = new CaseRole(1, "test"); var individual2 = individuals.Last(); individual2.CaseRole = new CaseRole(2, "test2"); var representative = hearing.GetParticipants().Single(x => x is Representative); representative.CaseRole = new CaseRole(3, "test3"); var judge = hearing.GetParticipants().Single(x => x is Judge); judge.CaseRole = new CaseRole(3, "test4"); var joh = hearing.GetParticipants().Single(x => x is JudicialOfficeHolder); joh.CaseRole = new CaseRole(4, "test5"); var staffMember = hearing.GetParticipants().Single(x => x is StaffMember); staffMember.CaseRole = new CaseRole(5, "test5"); hearing.AddEndpoints(new List <Endpoint> { new Endpoint("one", Guid.NewGuid().ToString(), "1234", null), new Endpoint("two", Guid.NewGuid().ToString(), "1234", representative) }); var hearingIsReadyForVideoIntegrationEvent = new HearingIsReadyForVideoIntegrationEvent(hearing); _eventPublisher.PublishAsync(hearingIsReadyForVideoIntegrationEvent); _serviceBusQueueClient.Count.Should().Be(1); var @event = _serviceBusQueueClient.ReadMessageFromQueue(); @event.IntegrationEvent.Should().BeOfType <HearingIsReadyForVideoIntegrationEvent>(); var typedEvent = (HearingIsReadyForVideoIntegrationEvent)@event.IntegrationEvent; typedEvent.Hearing.RecordAudio.Should().Be(hearing.AudioRecordingRequired); typedEvent.Participants.Count.Should().Be(hearing.GetParticipants().Count); typedEvent.Endpoints.Should().NotBeNull(); typedEvent.Endpoints.Count.Should().Be(hearing.GetEndpoints().Count); }
private static VideoHearing BuildHearing(bool leadCase) { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("Test 001 ", "Case name", leadCase); foreach (var participant in hearing.Participants) { participant.HearingRole = new HearingRole(1, "Name") { UserRole = new UserRole(1, "Judge"), }; participant.CaseRole = new CaseRole(1, "Name"); } return(hearing); }
private static VideoHearing GetHearing() { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("123", "Case name", true); foreach (var participant in hearing.Participants) { participant.HearingRole = new HearingRole(1, "Name") { UserRole = new UserRole(1, "User"), }; participant.CaseRole = new CaseRole(1, "Name"); } return(hearing); }
protected static VideoHearing GetHearing(string caseNumber) { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase(caseNumber, "Case name", true); foreach (var participant in hearing.Participants) { participant.HearingRole = new HearingRole(1, "Name") { UserRole = new UserRole(1, "User"), }; participant.CaseRole = new CaseRole(1, "Name"); } return(hearing); }
protected VideoHearing GetVideoHearing(bool createdStatus = false) { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("123", "Case name", true); hearing.CaseType = CaseType; foreach (var participant in hearing.Participants) { participant.HearingRole = new HearingRole(1, "Name") { UserRole = new UserRole(1, "User"), }; participant.CaseRole = new CaseRole(1, "Generic"); } if (createdStatus) { hearing.UpdateStatus(BookingsApi.Domain.Enumerations.BookingStatus.Created, "administrator", string.Empty); } return(hearing); }
public void Should_publish_message_to_queue_when_HearingDetailsUpdatedIntegrationEvent_is_raised() { var hearing = new VideoHearingBuilder().Build(); hearing.CaseType = new CaseType(1, "test"); hearing.AddCase("1234", "test", true); var hearingDetailsUpdatedIntegrationEvent = new HearingDetailsUpdatedIntegrationEvent(hearing); _eventPublisher.PublishAsync(hearingDetailsUpdatedIntegrationEvent); _serviceBusQueueClient.Count.Should().Be(1); var @event = _serviceBusQueueClient.ReadMessageFromQueue(); @event.IntegrationEvent.Should().BeOfType <HearingDetailsUpdatedIntegrationEvent>(); var typedEvent = (HearingDetailsUpdatedIntegrationEvent)@event.IntegrationEvent; typedEvent.Hearing.CaseName.Should().Be(hearing.GetCases().First().Name); typedEvent.Hearing.CaseNumber.Should().Be(hearing.GetCases().First().Number); typedEvent.Hearing.CaseType.Should().Be(hearing.CaseType.Name); typedEvent.Hearing.RecordAudio.Should().Be(hearing.AudioRecordingRequired); }
private static VideoHearing GetHearing() { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("123", "Case name", true); foreach (var participant in hearing.Participants) { participant.HearingRole = new HearingRole(1, "Name") { UserRole = new UserRole(1, "User"), }; participant.CaseRole = new CaseRole(1, "Name"); } var individuals = hearing.Participants.Where(x => x is Individual).ToList(); if (individuals.Count < 2) { Assert.Fail("Not enough individuals in test hearing to link participants"); } individuals[0].AddLink(individuals[1].Id, LinkedParticipantType.Interpreter); return(hearing); }
public void should_map_hearing_to_command() { var totalDays = 5; var hearingDay = 2; var hearing = new VideoHearingBuilder().Build(); hearing.AddEndpoint(new Endpoint("Endpoint1", $"{Guid.NewGuid():N}@hmcts.net", "1234", null)); hearing.AddEndpoint(new Endpoint("Endpoint2", $"{Guid.NewGuid():N}@hmcts.net", "2345", hearing.GetParticipants().First(x => x.HearingRole.UserRole.IsRepresentative))); hearing.AddCase("HBS/1234", "Case 1 Test", true); var individualsInHearing = hearing.Participants.Where(x => x.HearingRole.UserRole.IsIndividual).ToList(); individualsInHearing[0].AddLink(individualsInHearing[1].Id, LinkedParticipantType.Interpreter); individualsInHearing[1].AddLink(individualsInHearing[0].Id, LinkedParticipantType.Interpreter); var newDate = hearing.ScheduledDateTime.AddDays(1); var command = CloneHearingToCommandMapper.CloneToCommand(hearing, newDate, _randomGenerator, _sipAddressStem, totalDays, hearingDay); command.HearingRoomName.Should().Be(hearing.HearingRoomName); command.OtherInformation.Should().Be(hearing.OtherInformation); command.CreatedBy.Should().Be(hearing.CreatedBy); command.CaseType.Should().Be(hearing.CaseType); command.HearingType.Should().Be(hearing.HearingType); command.ScheduledDateTime.Should().Be(newDate); command.ScheduledDateTime.Hour.Should().Be(hearing.ScheduledDateTime.Hour); command.ScheduledDateTime.Minute.Should().Be(hearing.ScheduledDateTime.Minute); command.ScheduledDuration.Should().Be(480); command.Venue.Should().Be(hearing.HearingVenue); command.Participants.Count.Should().Be(hearing.GetParticipants().Count); foreach (var newParticipant in command.Participants) { var existingPerson = hearing.GetPersons().SingleOrDefault(x => x.Username == newParticipant.Person.Username); existingPerson.Should().NotBeNull(); var existingPat = hearing.Participants.Single(x => x.Person == existingPerson); newParticipant.DisplayName.Should().Be(existingPat.DisplayName); newParticipant.CaseRole.Should().Be(existingPat.CaseRole); newParticipant.HearingRole.Should().Be(existingPat.HearingRole); if (existingPat.GetType() != typeof(Representative)) { continue; } var rep = (Representative)existingPat; newParticipant.Representee.Should().Be(rep.Representee); } command.Cases.Count.Should().Be(hearing.GetCases().Count); foreach (var @case in command.Cases) { hearing.GetCases().SingleOrDefault(x => x.Number == @case.Number).Should() .NotBeNull(); @case.Name.Should().Contain($"Day {hearingDay} of {totalDays}"); } command.Endpoints.Count.Should().Be(hearing.GetEndpoints().Count); foreach (var ep in command.Endpoints) { hearing.GetEndpoints().SingleOrDefault(x => x.DisplayName == ep.DisplayName && x.DefenceAdvocate?.Person?.Username == ep.DefenceAdvocateUsername).Should().NotBeNull(); } command.QuestionnaireNotRequired.Should().BeTrue(); command.AudioRecordingRequired.Should().Be(hearing.AudioRecordingRequired); }