public USAddress(USAddress other)
 {
     Street  = other.Street;
     City    = other.City;
     State   = other.State;
     ZipCode = other.ZipCode;
 }
示例#2
0
        public void TestGetUSAddressDoctorType_HasExplanationCode()
        {
            var address1        = "1";
            var address2        = "2";
            var city            = "city";
            var state           = "FL";
            var postalCode      = "12345";
            var explanationCode = USAddrDoctorTypeExplanationCode.OM;
            var explanation     = "explanation";
            var address         = new USAddress(
                address1: address1,
                address2: address2,
                city: city,
                state: state,
                postalCode: postalCode,
                explanationCode: explanationCode.ToString(),
                explanation: explanation
                );

            var instance = address.GetUSAddressDoctorType();

            Assert.AreEqual(address.Address1, instance.Address1);
            Assert.AreEqual(address.Address2, instance.Address2);
            Assert.AreEqual(address.City, instance.City);
            Assert.AreEqual(address.State.GetStateCodeType(), instance.State);
            Assert.AreEqual(address.PostalCode, instance.PostalCode);
            Assert.AreEqual(address.Explanation, instance.Explanation);

            Assert.IsTrue(instance.ExplanationCodeSpecified);
            Assert.AreEqual(explanationCode, instance.ExplanationCode);
        }
示例#3
0
        public void TestConstructor()
        {
            var address1        = "1";
            var address2        = "2";
            var city            = "city";
            var state           = "FL";
            var postalCode      = "12345";
            var explanationCode = "code";
            var explanation     = "explanation";
            var address         = new USAddress(
                address1,
                address2,
                city,
                state,
                postalCode,
                explanationCode,
                explanation
                );

            Assert.AreEqual(address1, address.Address1);
            Assert.AreEqual(address2, address.Address2);
            Assert.AreEqual(city, address.City);
            Assert.AreEqual(state.GetStateCodeType().ToString(), address.State);
            Assert.AreEqual(postalCode, address.PostalCode);
            Assert.AreEqual(explanation, address.Explanation);
            Assert.AreEqual(explanationCode, address.ExplanationCode);
        }
 public void ShouldGetValesFromFacade()
 {
     USAddress.GetStreet().Length.ShouldBeGreaterThan(0);
     USAddress.GetStateAbbreviation().Length.ShouldBe(2);
     USAddress.GetZipCode().Length.ShouldBe(5);
     USAddress.GetCityCode().Length.ShouldBeGreaterThan(0);
     USAddress.GetAddressNumber().Length.ShouldBeGreaterThan(0);
 }
示例#5
0
        public static List <USAddress> CreateAddresses()
        {
            List <USAddress> addressesList = new List <USAddress>();
            List <Contact>   contacts      = new List <Contact>();
            // contact 1
            Contact contact = new Contact {
                FirstName = "jorge", LastName = "perez", Id = 1
            };

            contacts.Add(contact);
            USAddress address0 = new USAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 2, Country = "USA", ZipCode = "33283", Parent = contact
            };
            USAddress address1 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 11, Country = "USA", ZipCode = "33282", Parent = contact
            };

            contact.Addresses.Add(address0);
            contact.Addresses.Add(address1);
            addressesList.Add(address0);
            addressesList.Add(address1);
            // contact 2
            Contact contact2 = new Contact {
                FirstName = "jorge2", LastName = "perez2", Id = 2
            };

            contacts.Add(contact2);
            USAddress address2 = new USAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 1, Country = "USA", ZipCode = "33333", Parent = contact2
            };
            USAddress address3 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 5, Country = "USA", ZipCode = "33282", Parent = contact2
            };

            contact2.Addresses.Add(address2);
            contact2.Addresses.Add(address3);
            addressesList.Add(address2);
            addressesList.Add(address3);
            // contact 3
            Contact contact3 = new Contact {
                FirstName = "jorge3", LastName = "perez3", Id = 3
            };

            contacts.Add(contact3);
            USAddress address4 = new USAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 55, Country = "USA", ZipCode = "33333", Parent = contact3
            };
            USAddress address5 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 3, Country = "USA", ZipCode = "33282", Parent = contact3
            };

            contact3.Addresses.Add(address4);
            contact3.Addresses.Add(address5);
            addressesList.Add(address4);
            addressesList.Add(address5);
            return(addressesList);
        }
示例#6
0
        /// <summary>
        /// Geocodes the specified address.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <param name="result">The result.</param>
        /// <returns>
        /// True/False value of whether the address was standardized was succesfully
        /// </returns>
        public override bool Geocode(Rock.CRM.Address address, out string result)
        {
            if (address != null)
            {
                var registeredUser = new RegisteredUser();
                registeredUser.UserID   = AttributeValue("UserID");
                registeredUser.Password = AttributeValue("Password");

                var licenseInfo = new LicenseInfo();
                licenseInfo.RegisteredUser = registeredUser;

                var client = new USAddressVerificationSoapClient();

                SIWsOutputOfUSAddress verifyResult;
                SubscriptionInfo      info = client.VerifyAddressUSA(
                    licenseInfo,
                    address.Street1,
                    address.Street2,
                    string.Format("{0} {1} {2}",
                                  address.City,
                                  address.State,
                                  address.Zip),
                    string.Empty,
                    string.Empty,
                    CasingEnum.PROPER,
                    out verifyResult);

                if (verifyResult != null)
                {
                    result = verifyResult.ServiceStatus.StatusNbr.ToString();

                    if (verifyResult.ServiceStatus.StatusNbr == 200)
                    {
                        USAddress usAddress = verifyResult.ServiceResult;

                        if (usAddress != null && usAddress.GeoCode != null)
                        {
                            address.Latitude  = usAddress.GeoCode.Latitude;
                            address.Longitude = usAddress.GeoCode.Longitude;

                            return(true);
                        }
                    }
                }
                else
                {
                    result = "Null Result";
                }
            }
            else
            {
                result = "Null Address";
            }

            return(false);
        }
        public void CanCompareComplexModels()
        {
            var homeAddress = new USAddress()
            {
                Street  = "308 Negra Arroyo Lane",
                City    = "Albuquerque",
                State   = "New Mexico",
                ZipCode = 87104
            };

            var alternateAddress = new USAddress()
            {
                Street  = "Los Pollos Hermanos, 123 Central Ave Southeast",
                City    = "Albuquerque",
                State   = "New Mexico",
                ZipCode = 87108
            };

            var theOneWhoKnocks = new Customer()
            {
                FirstName  = "Walter",
                LastName   = "White",
                Aliases    = new[] { "Heisenberg", "The One Who Knocks" },
                Age        = 51,
                Address    = homeAddress,
                Directions = new List <Direction?>()
                {
                    null, Direction.Left, null, Direction.Right
                },
                Occupations = new Dictionary <string, Address>()
                {
                    { "Husband and father", homeAddress },
                    { "Career criminal", alternateAddress }
                }
            };

            var walterWhite = theOneWhoKnocks.Clone();

            var gustavoFring = new Customer()
            {
                FirstName = "Gustavo",
                LastName  = "Fring",
                Age       = 49,
                Address   = alternateAddress
            };

            var comparer = new ModelComparer <Customer>();

            Assert.Equal(theOneWhoKnocks, theOneWhoKnocks, comparer);
            Assert.Equal(walterWhite, theOneWhoKnocks, comparer);
            Assert.NotEqual(gustavoFring, theOneWhoKnocks, comparer);
        }
示例#8
0
        public static List <Contact> CreateContacts()
        {
            List <Contact> contacts = new List <Contact>();

            for (int i = 0; i < 100; i++)
            {
                Contact contact = new Contact();
                contact.LastName  = "Perez" + i.ToString(CultureInfo.InvariantCulture);
                contact.FirstName = "Jorge" + i.ToString(CultureInfo.InvariantCulture);
                contact.Id        = i;
                contact.Father    = new Contact()
                {
                    FirstName = "Frank", LastName = "Perez", Age = 67
                };
                // create phones
                for (int j = 0; j < 3; j++)
                {
                    Phone phone = new Phone();
                    phone.Number = "111-111" + j.ToString(CultureInfo.InvariantCulture);
                    contact.Phones.Add(phone);
                }
                // create addresses
                for (int j = 0; j < 4; j++)
                {
                    string zip = string.Empty;
                    if (contact.LastName.EndsWith("1"))
                    {
                        zip = "1111" + j.ToString(CultureInfo.InvariantCulture);
                    }
                    else
                    {
                        zip = "2222" + j.ToString(CultureInfo.InvariantCulture);
                    }
                    USAddress address = new USAddress();
                    address.Street  = "100 nw 133" + j.ToString(CultureInfo.InvariantCulture);
                    address.ZipCode = zip;
                    address.City    = "Miami" + j.ToString(CultureInfo.InvariantCulture);
                    address.Country = "USA" + j.ToString();
                    address.Parent  = contact;
                    for (int k = 0; k < 5; k++)
                    {
                        AddressType addressType = new AddressType();
                        addressType.Id   = k.ToString();
                        addressType.Name = "type" + k.ToString();
                        address.AddressType.Add(addressType);
                    }
                    contact.Addresses.Add(address);
                }
                contacts.Add(contact);
            }
            return(contacts);
        }
示例#9
0
        static string Format(USAddress a)
        {
            string variablePart = null;

            if (a.Street != null)
            {
                variablePart = a.Street;
            }
            else if (a.POBox != null)
            {
                variablePart = "PO Box " + a.POBox;
            }
            return
                (variablePart + "\n"
                 + a.City + ", "
                 + a.State + " "
                 + a.Zip);
        }
示例#10
0
        public static string Format(this USAddress anAddress)
        {
            string variablePart = null;

            if (anAddress.Street != null)
            {
                variablePart = anAddress.Street;
            }
            else if (anAddress.POBox != null)
            {
                variablePart = "PO Box " + anAddress.POBox;
            }
            return
                (variablePart + "\n"
                 + anAddress.City + ", "
                 + anAddress.State + " "
                 + anAddress.Zip);
        }
示例#11
0
        public static void Run()
        {
            // Explicit cloning
            var po1 = PurchaseOrder.Load("../../Data/po1.xml");
            var po2 = (PurchaseOrder)po1.Clone();
            po2.CompareWithBaseline("Clone.xml");

            // Implicit cloning
            var po = new PurchaseOrder();
            var adr = new USAddress();
            adr.Country = "US";
            adr.City = "Mercer Island";
            adr.Name = "Patrick Hines";
            adr.State = "WA";
            adr.Street = "123 Main St";
            adr.Zip = 68042;
            po.BillTo = adr;
            po.ShipTo = adr;
            po.BillTo.Equals(adr).Require();
            (!po.BillTo.Equals(po.ShipTo)).Require();
        }
示例#12
0
        public static void Run()
        {
            // Explicit cloning
            var po1 = PurchaseOrder.Load("../../Data/po1.xml");
            var po2 = (PurchaseOrder)po1.Clone();

            po2.CompareWithBaseline("Clone.xml");

            // Implicit cloning
            var po  = new PurchaseOrder();
            var adr = new USAddress();

            adr.Country = "US";
            adr.City    = "Mercer Island";
            adr.Name    = "Patrick Hines";
            adr.State   = "WA";
            adr.Street  = "123 Main St";
            adr.Zip     = 68042;
            po.BillTo   = adr;
            po.ShipTo   = adr;
            po.BillTo.Equals(adr).Require();
            (!po.BillTo.Equals(po.ShipTo)).Require();
        }
示例#13
0
        public void TestGetUSAddressDoctorType_DoesNotHaveExplanationCode()
        {
            var address1    = "1";
            var address2    = "2";
            var city        = "city";
            var state       = "FL";
            var postalCode  = "12345";
            var explanation = "explanation";
            var address     = new USAddress(
                address1: address1,
                address2: address2,
                city: city,
                state: state,
                postalCode: postalCode,
                explanationCode: null,
                explanation: explanation
                );

            var instance = address.GetUSAddressDoctorType();

            Assert.IsFalse(instance.ExplanationCodeSpecified);
            Assert.IsNull(instance.ExplanationCode);
        }
示例#14
0
        public void TestGetUSAddressDoctorType_DoesNotHaveState()
        {
            var    address1        = "1";
            var    address2        = "2";
            var    city            = "city";
            string state           = null;
            var    postalCode      = "12345";
            var    explanationCode = USAddrDoctorTypeExplanationCode.OM;
            var    explanation     = "explanation";
            var    address         = new USAddress(
                address1: address1,
                address2: address2,
                city: city,
                state: state,
                postalCode: postalCode,
                explanationCode: explanationCode.ToString(),
                explanation: explanation
                );

            var instance = address.GetUSAddressDoctorType();

            Assert.IsFalse(instance.StateSpecified);
        }
示例#15
0
        public static List <Contact> CreateContactsForGrouping()
        {
            List <Contact> contacts = new List <Contact>();
            // contact 1
            Contact contact = new Contact {
                FirstName = "jorge", LastName = "perez", Id = 1, Age = 14, Salary = 20000
            };

            contacts.Add(contact);
            CubanAddress address0 = new CubanAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 2, Country = "USA", Parent = contact
            };
            CubanAddress address1 = new CubanAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 11, Country = "USA", Parent = contact
            };

            contact.Addresses.Add(address0);
            contact.Addresses.Add(address1);
            // contact 2
            Contact contact2 = new Contact {
                FirstName = "jorge2", LastName = "perez3", Id = 2, Age = 15, Salary = 10000
            };

            contacts.Add(contact2);
            USAddress address2 = new USAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 1, Country = "USA", ZipCode = "33333", Parent = contact2
            };
            USAddress address3 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 5, Country = "USA", ZipCode = "33282", Parent = contact2
            };

            contact2.Addresses.Add(address2);
            contact2.Addresses.Add(address3);
            // contact 3
            Contact contact3 = new Contact {
                FirstName = "jorge3", LastName = "perez3", Id = 3, Age = 14, Salary = 30000
            };

            contacts.Add(contact3);
            USAddress address4 = new USAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 55, Country = "USA", ZipCode = "33333", Parent = contact3
            };
            USAddress address5 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 3, Country = "USA", ZipCode = "33282", Parent = contact3
            };

            contact3.Addresses.Add(address4);
            contact3.Addresses.Add(address5);
            // contact 4
            Contact contact4 = new Contact {
                FirstName = "jorge4", LastName = "perez3", Id = 4, Age = 15, Salary = 11111
            };

            contacts.Add(contact4);
            USAddress address6 = new USAddress {
                Street = "1000 nw 136 ave", City = "Miami", Id = 55, Country = "USA", ZipCode = "33333", Parent = contact4
            };
            USAddress address7 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 3, Country = "USA", ZipCode = "33282", Parent = contact4
            };

            contact4.Addresses.Add(address4);
            contact4.Addresses.Add(address5);
            // contact 5
            Contact contact5 = new Contact {
                FirstName = "jorge3", LastName = "perez3", Id = 4, Age = 15, Salary = 22222
            };

            contacts.Add(contact5);
            USAddress address8 = new USAddress {
                Street = "1000 nw 136 ave", City = "Hialeah", Id = 55, Country = "USA", ZipCode = "32165", Parent = contact5
            };
            USAddress address9 = new USAddress {
                Street = "222 nw 222 ave", City = "Miami", Id = 3, Country = "USA", ZipCode = "33282", Parent = contact5
            };

            contact3.Addresses.Add(address8);
            contact3.Addresses.Add(address9);

            //return list
            return(contacts);
        }
示例#16
0
        /// <summary>
        /// Standardizes the specified address.
        /// </summary>
        /// <remarks>
        /// The StrikeIron address verification will also attempt to geocode the address.  If this
        /// geocode is succesful, the Geocode information of the address will be updated also.
        /// </remarks>
        /// <param name="location">The location.</param>
        /// <param name="result">The result.</param>
        /// <returns>
        /// True/False value of whether the address was standardized was succesfully
        /// </returns>
        public override bool Standardize(Rock.Model.Location location, out string result)
        {
            if (location != null)
            {
                var registeredUser = new RegisteredUser();
                registeredUser.UserID   = GetAttributeValue("UserID");
                registeredUser.Password = GetAttributeValue("Password");

                var licenseInfo = new LicenseInfo();
                licenseInfo.RegisteredUser = registeredUser;

                var client = new USAddressVerificationSoapClient();

                SIWsOutputOfUSAddress verifyResult;
                SubscriptionInfo      info = client.VerifyAddressUSA(
                    licenseInfo,
                    location.Street1,
                    location.Street2,
                    string.Format("{0} {1} {2}",
                                  location.City,
                                  location.State,
                                  location.Zip),
                    string.Empty,
                    string.Empty,
                    CasingEnum.PROPER,
                    out verifyResult);

                if (verifyResult != null)
                {
                    result = verifyResult.ServiceStatus.StatusNbr.ToString();

                    if (verifyResult.ServiceStatus.StatusNbr == 200)
                    {
                        USAddress usAddress = verifyResult.ServiceResult;

                        if (usAddress != null && usAddress.GeoCode != null)
                        {
                            location.Street1 = usAddress.AddressLine1;
                            location.Street2 = usAddress.AddressLine2;
                            location.City    = usAddress.City;
                            location.State   = usAddress.State;
                            location.Zip     = usAddress.ZIPPlus4;

                            if (usAddress.GeoCode != null)
                            {
                                location.GeocodeAttemptedServiceType = "StrikeIron";
                                location.GeocodeAttemptedResult      = "200";
                                location.GeocodedDateTime            = DateTime.Now;

                                location.SetLocationPointFromLatLong(usAddress.GeoCode.Latitude, usAddress.GeoCode.Longitude);
                            }

                            return(true);
                        }
                    }
                }
                else
                {
                    result = "Null Result";
                }
            }
            else
            {
                result = "Null Address";
            }

            return(false);
        }