public static PersonalRelationship CreatePersonalRelationship(
     Person person,
     Person otherPerson,
     PersonalRelationshipType type,
     bool hasEnded = false,
     long?id       = null
     )
 {
     return(new Faker <PersonalRelationship>()
            .RuleFor(pr => pr.Id, f => id ?? f.UniqueIndex)
            .RuleFor(pr => pr.PersonId, person.Id)
            .RuleFor(pr => pr.OtherPersonId, otherPerson.Id)
            .RuleFor(pr => pr.OtherPerson, otherPerson)
            .RuleFor(pr => pr.TypeId, type.Id)
            .RuleFor(pr => pr.Type, type)
            .RuleFor(pr => pr.StartDate, f => f.Date.Past())
            .RuleFor(pr => pr.EndDate, f => hasEnded ? f.Date.Future() : (DateTime?)null)
            .RuleFor(pr => pr.IsInformalCarer, f => f.Random.String2(1, "YN"))
            .RuleFor(pr => pr.ParentalResponsibility, f => f.Random.String2(1, "YN")));
 }
        public void CanMapPersonDetailsToGetPersonResponse()
        {
            Person person = DatabaseGatewayHelper.CreatePersonDatabaseEntity();

            person.Id = 123;

            Address address = DatabaseGatewayHelper.CreateAddressDatabaseEntity(person.Id);

            //set to display address
            address.IsDisplayAddress = "Y";

            PhoneNumber phoneNumber1 = DatabaseGatewayHelper.CreatePhoneNumberEntity(person.Id);
            PhoneNumber phoneNumber2 = DatabaseGatewayHelper.CreatePhoneNumberEntity(person.Id);

            PersonOtherName otherName1 = DatabaseGatewayHelper.CreatePersonOtherNameDatabaseEntity(person.Id);
            PersonOtherName otherName2 = DatabaseGatewayHelper.CreatePersonOtherNameDatabaseEntity(person.Id);

            person.Addresses = new List <Address>
            {
                address
            };

            person.PhoneNumbers = new List <PhoneNumber>
            {
                phoneNumber1,
                phoneNumber2
            };

            person.OtherNames = new List <PersonOtherName>
            {
                otherName1,
                otherName2
            };

            AddressDomain addressDomain = new AddressDomain()
            {
                Address  = address.AddressLines,
                Postcode = address.PostCode,
                Uprn     = address.Uprn
            };

            OtherName personOtherName1 = new OtherName()
            {
                FirstName = otherName1.FirstName,
                LastName  = otherName1.LastName
            };

            OtherName personOtherName2 = new OtherName()
            {
                FirstName = otherName2.FirstName,
                LastName  = otherName2.LastName
            };

            PhoneNumberDomain phoneNumberDomain1 = new PhoneNumberDomain()
            {
                Number = phoneNumber1.Number,
                Type   = phoneNumber1.Type
            };

            PhoneNumberDomain phoneNumberDomain2 = new PhoneNumberDomain()
            {
                Number = phoneNumber2.Number,
                Type   = phoneNumber2.Type
            };

            var expectedResponse = new GetPersonResponse()
            {
                EmailAddress      = person.EmailAddress,
                DateOfBirth       = person.DateOfBirth.Value,
                DateOfDeath       = person.DateOfDeath.Value,
                Address           = addressDomain,
                SexualOrientation = person.SexualOrientation,
                ContextFlag       = person.AgeContext,
                CreatedBy         = person.CreatedBy,
                Ethnicity         = person.Ethnicity,
                FirstLanguage     = person.FirstLanguage,
                FirstName         = person.FirstName,
                Gender            = person.Gender,
                LastName          = person.LastName,
                NhsNumber         = person.NhsNumber.Value,
                Id = person.Id,
                PreferredMethodOfContact = person.PreferredMethodOfContact,
                Religion   = person.Religion,
                Restricted = person.Restricted,
                Title      = person.Title,
                OtherNames = new List <OtherName>()
                {
                    personOtherName1, personOtherName2
                },
                PhoneNumbers = new List <PhoneNumberDomain>()
                {
                    phoneNumberDomain1, phoneNumberDomain2
                }
            };

            var result = ResponseFactory.ToResponse(person);

            result.Should().BeEquivalentTo(expectedResponse);
        }
예제 #3
0
        public static MashResident CreateMashResident(DatabaseContext databaseContext, MashReferral referral, DbPerson personMatch = null)
        {
            var mashResident = new Faker <MashResident>()
                               .RuleFor(r => r.Id, f => f.UniqueIndex)
                               .RuleFor(r => r.FirstName, f => personMatch?.FirstName ?? f.Person.FirstName)
                               .RuleFor(r => r.LastName, f => personMatch?.LastName ?? f.Person.LastName)
                               .RuleFor(r => r.DateOfBirth, f => personMatch?.DateOfBirth ?? f.Person.DateOfBirth)
                               .RuleFor(r => r.Gender, f => personMatch?.Gender ?? f.Random.String2(1, "MF"))
                               .RuleFor(r => r.Ethnicity, f => personMatch?.Ethnicity ?? f.Commerce.Color())
                               .RuleFor(r => r.FirstLanguage, f => personMatch?.FirstLanguage ?? f.Random.Word())
                               .RuleFor(r => r.School, f => f.Random.String2(1, 5))
                               .RuleFor(r => r.Address, f => f.Address.State())
                               .RuleFor(r => r.Postcode, f => f.Address.ZipCode())
                               .RuleFor(r => r.SocialCareId, f => personMatch?.Id ?? f.UniqueIndex)
                               .Generate();

            mashResident.MashReferralId = referral.Id;
            mashResident.MashReferral   = referral;


            databaseContext.MashResidents.Add(mashResident);
            databaseContext.SaveChanges();

            return(mashResident);
        }