public static OtherName ToDomain(this PersonOtherName otherName)
 {
     return(new OtherName()
     {
         FirstName = otherName.FirstName,
         LastName = otherName.LastName
     });
 }
        public void CanMapPersonOtherNameFromDatabaseObjectToDomainObject()
        {
            PersonOtherName otherName = DatabaseGatewayHelper.CreatePersonOtherNameDatabaseEntity(_faker.Random.Long());

            var expectedResponse = new OtherName()
            {
                FirstName = otherName.FirstName,
                LastName  = otherName.LastName
            };

            otherName.ToDomain().Should().BeEquivalentTo(expectedResponse);
        }
        public void CanMapOtherNameFromDomainToInfrastructure()
        {
            var firstName = _faker.Name.FirstName();
            var lastName  = _faker.Name.LastName();
            var createdBy = _faker.Internet.Email();

            var domainOtherName = new OtherName()
            {
                FirstName = firstName,
                LastName  = lastName
            };

            long personId = 123;

            var infrastructureOtherName = new PersonOtherName()
            {
                FirstName = firstName,
                LastName  = lastName,
                PersonId  = personId,
                CreatedBy = createdBy
            };

            domainOtherName.ToEntity(personId, createdBy).Should().BeEquivalentTo(infrastructureOtherName);
        }
        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);
        }