Sometimes the weirdest things come up when testing. I was helping with some

Integration Testing recently, and we needed to submit a new valid postal address with

every request to this system. That’s a hefty load to bear, and certainly if

I were doing Unit Testing I’d be mocking away that system just to not have to deal

with that problem, but for Integration Tests there was no way around it. My

answer? Public data my good friends.

The quest started with Google, as most do, and a search criteria like this :

City State Zip filetype:csv

Which after browsing for several pages I modified to:

City State Zip filetype:csv site:usps.com

That resulted in the CSV which is the source of the data we’re using, a list of Post

Offices across the nation. The list is very long, a total of 19,931 addresses.

Now, it wouldn’t be fair to just list the Google queries here, after all this is a

technical blog. I took the CSV apart, removed the irrelevant fields and parsed

it into an object to hold address data, specifically this object.

[Serializable]
              public
              class AddressData
{
              private
              string _Name;
              public
              string Name
    {
        get { return _Name;
}
        set
        {
            _Name = value;
        }
    }
              private
              string _StreetLine1;
              public
              string StreetLine1
    {
        get { return _StreetLine1;
}
        set
        {
            _StreetLine1 = value;
        }
    }
              private
              string _StreetLine2;
              public
              string StreetLine2
    {
        get { return _StreetLine2;
}
        set
        {
            _StreetLine2 = value;
        }
    }
              private
              string _City;
              public
              string City
    {
        get { return _City;
}
        set
        {
            _City = value;
        }
    }
              private
              string _State;
              public
              string State
    {
        get { return _State;
}
        set
        {
            _State = value;
        }
    }
              private
              string _Zip;
              public
              string Zip
    {
        get { return _Zip;
}
        set
        {
            _Zip = value;
        }
    }
}

Now if you compile your own version of that code, and create a List<AddressData>

you should be able to Deserialize

this file of all the addresses for your own use.