using System.Collections.Generic;
public static void Main()
new UnitTests().PerformUnitTest();
public void PerformUnitTest()
var sut = new CustomerValidator();
for (int i = 1000; i <= 99999; i++) {
string zipString = i >= 10000 ? i.ToString() : "0" + i.ToString();
sut.allZipCodes.Add(zipString);
Customer customer1 = new Customer() {
Customer customer2 = new Customer() {
var actual = sut.ValidateZip(customer1);
var result = expected == actual ? "PASS" : "FAIL";
Console.WriteLine(result);
actual = sut.ValidateZip(customer2);
result = expected == actual ? "PASS" : "FAIL";
Console.WriteLine(result);
public class CustomerValidator
public List<string> allZipCodes = new List<string>();
public bool GetCustomerAndValidateZip()
Customer customer = GetCustomer();
allZipCodes = GetAllValidZipCodes();
return ValidateZip(customer);
private Customer GetCustomer() {
var repository = new CustomerRepository();
int customerId = (int)HttpContext.Current.Profile.GetPropertyValue("CustomerId");
return repository.GetCustomer(customerId);
public bool ValidateZip(Customer customer) {
return allZipCodes.Contains(customer.ZipCode);
private List<string> GetAllValidZipCodes()
var httpClient = new HttpClient();
return httpClient.Get<List<string>>("http://somezipcodeapi.com/GetAll");
public int ID { get; set; }
public string ZipCode { get; set; }
public class CustomerRepository
public Customer GetCustomer(int customerId)
var db = new DbContext();
return db.Customers.SingleOrDefault(i => i.ID == customerId);
public List<Customer> Customers { get; set; }
public T Get<T>(string url)