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); }
public void Should_throw_exception_if_hearing_is_missing_case() { var mockedHearing = new VideoHearingBuilder().Build(); When(() => _mapper.MapHearingResponse(mockedHearing)) .Should().Throw <ArgumentException>().WithMessage("Hearing is missing case"); }
protected VideoHearing TestData(bool addSuitability = true) { var builder = new VideoHearingBuilder(); var hearing = builder.Build(); if (addSuitability) { var participant = hearing.Participants.FirstOrDefault(p => p is Individual); if (participant != null) { var answer = new SuitabilityAnswer("AboutYou", "Yes", "") { UpdatedDate = DateTime.Now.AddDays(-2) }; participant.Questionnaire = new Questionnaire { Participant = participant, ParticipantId = participant.Id }; participant.Questionnaire.SuitabilityAnswers.Add(answer); participant.Questionnaire.UpdatedDate = DateTime.Now.AddDays(-2); } } return(hearing); }
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>(); }
private VideoHearing MockHearingWithCase() { var hearing = new VideoHearingBuilder().Build(); hearing.AddCase("234", "X vs Y", true); return(hearing); }
public void Should_not_throw_domain_rule_exception_if_hearing_does_not_have_a_host() { //Arrange var hearing = new VideoHearingBuilder().Build(); //Act/Assert Assert.DoesNotThrow(() => hearing.ValidateHostCount()); }
public void Should_update_hearing_status_from_booked_to_cancelled() { var hearing = new VideoHearingBuilder().Build(); var updatedDate = DateTime.UtcNow; hearing.UpdateStatus(BookingStatus.Cancelled, "testuser", "cancel reason"); hearing.UpdatedDate.Should().BeAfter(updatedDate); hearing.Status.Should().Be(BookingStatus.Cancelled); }
public void Should_update_hearing_status() { var hearing = new VideoHearingBuilder().Build(); var updatedDate = hearing.UpdatedDate; hearing.UpdateStatus(BookingStatus.Cancelled, "testuser", "cancel reason"); hearing.UpdatedDate.Should().BeAfter(updatedDate); hearing.Status.Should().Be(BookingStatus.Cancelled); }
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_endpoint() { var hearing = new VideoHearingBuilder().Build(); var beforeAddCount = hearing.GetEndpoints().Count; hearing.AddEndpoint(new BookingsApi.Domain.Endpoint("DisplayName", "*****@*****.**", "1111", null)); var afterAddCount = hearing.GetEndpoints().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
public void Should_throw_argument_null_exception_when_cancel_reason_field_is_empty() { var hearing = new VideoHearingBuilder().Build(); var newStatus = BookingStatus.Cancelled; Action action = () => hearing.UpdateStatus(newStatus, "user", string.Empty); action.Should().Throw <ArgumentNullException>(); hearing.Status.Should().Be(BookingStatus.Booked); }
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_update_status_on_cancel() { var hearing = new VideoHearingBuilder().Build(); hearing.Status.Should().Be(BookingStatus.Booked); hearing.CancelHearing(); hearing.Status.Should().Be(BookingStatus.Cancelled); }
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); }
public void Should_throw_argument_null_exception_when_updatedby_field_is_null() { var hearing = new VideoHearingBuilder().Build(); var newStatus = BookingStatus.Cancelled; Action action = () => hearing.UpdateStatus(newStatus, null, "settled"); action.Should().Throw <ArgumentNullException>(); hearing.Status.Should().Be(BookingStatus.Booked); }
public void should_map_hearing_to_response_model_without_case() { var hearing = new VideoHearingBuilder().Build(); var result = HearingToUsernameForDeletionResponseMapper.MapToDeletionResponse(hearing); result.Venue.Should().Be(hearing.HearingVenueName); result.ScheduledDateTime.Should().Be(hearing.ScheduledDateTime); result.CaseName.Should().BeNullOrEmpty(); result.CaseNumber.Should().BeNullOrEmpty(); }
public void Should_return_log_info_with_videohearing() { var videoHearing = new VideoHearingBuilder().Build(); var result = HearingControlLogHelper.LogInfo(videoHearing); result.Should().NotBeNull(); result.Count.Should().Be(3); result["HearingId"].Should().Be(videoHearing.Id.ToString()); result["CaseType"].Should().Be(videoHearing.CaseType?.Name); result["Participants.Count"].Should().Be(videoHearing.Participants.Count.ToString()); }
public void Should_remove_existing_participant_from_hearing() { var hearing = new VideoHearingBuilder().Build(); var beforeCount = hearing.GetParticipants().Count; var participant = hearing.GetParticipants().First(); hearing.RemoveParticipant(participant); var afterCount = hearing.GetParticipants().Count; afterCount.Should().BeLessThan(beforeCount); }
public void Should_throw_domain_rule_exception_if_hearing_does_not_have_a_host() { //Arrange var hearing = new VideoHearingBuilder().Build(); hearing.Participants.Clear(); hearing.Participants.Add(new ParticipantBuilder().IndividualParticipantApplicant); //Act/Assert Assert.Throws <DomainRuleException>(() => hearing.ValidateHostCount()); }
public void Should_throw_domain_exception_Upon_hearing_status_update_to_booked() { var hearing = new VideoHearingBuilder().Build(); var updatedDate = hearing.UpdatedDate; var newStatus = BookingStatus.Booked; Action action = () => hearing.UpdateStatus(newStatus, "testuser", null); action.Should().Throw <DomainRuleException>().And.ValidationFailures .Any(x => x.Message == $"Cannot change the booking status from {hearing.Status} to {newStatus}").Should().BeTrue(); hearing.Status.Should().Be(BookingStatus.Booked); hearing.UpdatedDate.Should().Be(updatedDate); }
public void Should_update_hearing_status_to_created() { var hearing = new VideoHearingBuilder().Build(); var updatedDate = DateTime.UtcNow; var updatedBy = "testuser"; hearing.UpdateStatus(BookingStatus.Created, updatedBy, ""); hearing.UpdatedDate.Should().BeAfter(updatedDate); hearing.Status.Should().Be(BookingStatus.Created); hearing.ConfirmedBy.Should().Be(updatedBy); hearing.ConfirmedDate.Should().NotBeNull(); }
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); }
public void Should_raise_exception_if_adding_judge_twice() { var hearingBuilder = new VideoHearingBuilder(); var hearing = hearingBuilder.Build(); var existingJudge = hearingBuilder.Judge; var judgeCaseRole = new CaseRole(5, "Judge"); var judgeHearingRole = new HearingRole(13, "Judge"); var newPerson = new PersonBuilder(existingJudge.Username).Build(); When(() => hearing.AddJudge(newPerson, judgeHearingRole, judgeCaseRole, "Judge Dredd")) .Should().Throw <DomainRuleException>().WithMessage("Judge with given username already exists in the hearing"); }
public void Should_raise_exception_if_adding_judicial_office_holder_twice() { var hearingBuilder = new VideoHearingBuilder(); var hearing = hearingBuilder.Build(); var existingJoh = hearingBuilder.JudicialOfficeHolder; var johCaseRole = new CaseRole(7, "Judicial Office Holder"); var johHearingRole = new HearingRole(14, "Judicial Office Holder"); var newPerson = new PersonBuilder(existingJoh.Username).Build(); When(() => hearing.AddJudicialOfficeHolder(newPerson, johHearingRole, johCaseRole, "Joh")) .Should().Throw <DomainRuleException>().WithMessage("Judicial office holder already exists in the hearing"); }
public void Should_add_judge_to_hearing() { var hearing = new VideoHearingBuilder().Build(); var judgeCaseRole = new CaseRole(5, "Judge"); var judgeHearingRole = new HearingRole(13, "Judge"); var newPerson = new PersonBuilder(true).Build(); var beforeAddCount = hearing.GetParticipants().Count; hearing.AddJudge(newPerson, judgeHearingRole, judgeCaseRole, "Judge Display Name"); var afterAddCount = hearing.GetParticipants().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
public void Should_add_judicial_office_holder_to_hearing() { var hearing = new VideoHearingBuilder().Build(); var johCaseRole = new CaseRole(7, "Judicial Office Holder"); var johHearingRole = new HearingRole(14, "Judicial Office Holder"); var newPerson = new PersonBuilder(true).Build(); var beforeAddCount = hearing.GetParticipants().Count; hearing.AddJudicialOfficeHolder(newPerson, johHearingRole, johCaseRole, "Joh Display Name"); var afterAddCount = hearing.GetParticipants().Count; afterAddCount.Should().BeGreaterThan(beforeAddCount); }
public void should_update_status_from_failed_to_created() { var hearing = new VideoHearingBuilder().Build(); hearing.SetProtected(nameof(hearing.Status), BookingStatus.Failed); hearing.SetProtected(nameof(hearing.UpdatedDate), DateTime.UtcNow); var updatedDate = hearing.UpdatedDate; var newStatus = BookingStatus.Created; hearing.UpdateStatus(newStatus, "testuser", null); hearing.Status.Should().Be(BookingStatus.Created); hearing.UpdatedDate.Should().BeAfter(updatedDate); }