public void CanMapPhoneNumberFromDatabaseEntityToDomainObject()
        {
            dbPhoneNumber phoneNumber = DatabaseGatewayHelper.CreatePhoneNumberEntity(_faker.Random.Long());

            var expectedResponse = new PhoneNumber()
            {
                Number = phoneNumber.Number,
                Type   = phoneNumber.Type
            };

            phoneNumber.ToDomain().Should().BeEquivalentTo(expectedResponse);
        }
        public void CanMapPhoneNumberFromDomainToInfrastructure()
        {
            string phoneNumber     = "12345678";
            string phoneNumberType = "Mobile";
            long   personId        = 123;
            string createdBy       = _faker.Internet.Email();

            var domainNumber = new PhoneNumber()
            {
                Number = phoneNumber,
                Type   = phoneNumberType
            };

            var infrastructurePhoneNumber = new dbPhoneNumber()
            {
                Number    = phoneNumber,
                PersonId  = personId,
                Type      = phoneNumberType,
                CreatedBy = createdBy
            };

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