public void Setup() { //orgranisation table setup organisation = new Organisation("strawhat"); //persons record IndividualPerson = new Person("mr", "luffy", "dragon", "*****@*****.**") { ContactEmail = "*****@*****.**", Organisation = organisation }; JudgePerson = new Person("mr", "zoro", "rononora", "*****@*****.**") { ContactEmail = "*****@*****.**", Organisation = organisation }; JudicialOfficeHolderPerson = new Person("mr", "luffy", "dragon", "*****@*****.**") { ContactEmail = "*****@*****.**", Organisation = organisation }; StaffMemberPerson = new Person("mr", "luffy", "duffy", "*****@*****.**") { ContactEmail = "*****@*****.**", Organisation = organisation }; //participants record IndividualParticipant = new Individual(IndividualPerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "Individual" }; var IndividualParticipant2 = new Individual(IndividualPerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "Individual" }; JudgeParticipant = new Judge(JudgePerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "Judge" }; JudicialOfficeHolderParticipant = new JudicialOfficeHolder(JudicialOfficeHolderPerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "JudicialOfficeHolder" }; StaffMemberParticipant = new JudicialOfficeHolder(StaffMemberPerson, new HearingRole(719, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "StaffMember" }; _context.Persons.AddRange(IndividualPerson, JudgePerson, JudicialOfficeHolderPerson, StaffMemberPerson); _context.Participants.AddRange(IndividualParticipant, IndividualParticipant2, JudgeParticipant, JudicialOfficeHolderParticipant, StaffMemberParticipant); _context.SaveChanges(); _configOptions.Setup(opt => opt.Value).Returns(new FeatureFlagConfiguration() { EJudFeature = true }); _handler = new GetPersonBySearchTermQueryHandler(_context, _configOptions.Object); }
public void Setup() { _organisation = new Organisation(Faker.Company.Name()); _individualPerson = new Person(Faker.Name.Suffix(), Faker.Name.First(), Faker.Name.Last(), Faker.Internet.Email()) { ContactEmail = Faker.Internet.Email(), Organisation = _organisation }; _judgePerson = new Person(Faker.Name.Suffix(), Faker.Name.First(), Faker.Name.Last(), Faker.Internet.Email()) { ContactEmail = Faker.Internet.Email(), Organisation = _organisation }; _judicialOfficeHolderPerson = new Person(Faker.Name.Suffix(), Faker.Name.First(), Faker.Name.Last(), Faker.Internet.Email()) { ContactEmail = Faker.Internet.Email(), Organisation = _organisation }; _staffMemberPerson = new Person(Faker.Name.Suffix(), Faker.Name.First(), Faker.Name.Last(), Faker.Internet.Email()) { ContactEmail = Faker.Internet.Email(), Organisation = _organisation }; _repPerson = new Person(Faker.Name.Suffix(), Faker.Name.First(), Faker.Name.Last(), Faker.Internet.Email()) { ContactEmail = Faker.Internet.Email(), Organisation = _organisation }; _judgeParticipant = new Judge(_judgePerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "Judge" }; _individualParticipant = new Individual(_individualPerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "Individual" }; _judicialOfficeHolderParticipant = new JudicialOfficeHolder(_judicialOfficeHolderPerson, new HearingRole(123, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "JudicialOfficeHolder" }; _staffMemberParticipant = new JudicialOfficeHolder(_staffMemberPerson, new HearingRole(719, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "StaffMember" }; _repParticipant = new JudicialOfficeHolder(_repPerson, new HearingRole(719, "hearingrole"), new CaseRole(345, "caserole")) { Discriminator = "Representative" }; _context.Persons.AddRange(_individualPerson, _judgePerson, _judicialOfficeHolderPerson, _staffMemberPerson); _context.Participants.AddRange(_individualParticipant, _judgeParticipant, _judicialOfficeHolderParticipant, _staffMemberParticipant, _repParticipant); _context.SaveChanges(); _handler = new GetStaffMemberBySearchTermQueryHandler(_context); }
public Participant AddJudicialOfficeHolder(Person person, HearingRole hearingRole, CaseRole caseRole, string displayName) { if (DoesParticipantExist(person.Username)) { throw new DomainRuleException(nameof(person), "Judicial office holder already exists in the hearing"); } var participant = new JudicialOfficeHolder(person, hearingRole, caseRole) { DisplayName = displayName }; Participants.Add(participant); UpdatedDate = DateTime.Now; return(participant); }
public void Should_map_judicial_office_holder() { var caseRole = new CaseRole(7, "Judicial Office Holder"); var hearingRole = new HearingRole(14, "Judicial Office Holder") { UserRole = new UserRole(7, "Judicial Office Holder") }; var person = new PersonBuilder().Build(); var joh = new JudicialOfficeHolder(person, hearingRole, caseRole) { DisplayName = "JOH", CreatedBy = "*****@*****.**" }; joh.SetProtected(nameof(joh.CaseRole), caseRole); joh.SetProtected(nameof(joh.HearingRole), hearingRole); var response = _mapper.MapParticipantToResponse(joh); AssertParticipantCommonDetails(response, joh, caseRole, hearingRole); AssertRepresentativeResponse(response, null); response.Organisation.Should().BeNullOrWhiteSpace(); }