using System.Collections.Generic;
public static void Main()
new UnitTests().PerformUnitTest();
public void PerformUnitTest()
var sut = new CustomerValidator();
var actual = sut.GetCustomerAndValidateZip("11111");
var result = expected == actual ? "PASS" : "FAIL";
Console.WriteLine(result);
actual = sut.GetCustomerAndValidateZip("12345");
result = expected == actual ? "PASS" : "FAIL";
Console.WriteLine(result);
public class CustomerValidator
public bool GetCustomerAndValidateZip(string testZip = "")
var allZipCodes = new List<string>();
var customer = new Customer();
var useLiveServices = string.IsNullOrEmpty(testZip);
var repository = new CustomerRepository();
int customerId = (int)HttpContext.Current.Profile.GetPropertyValue("CustomerId");
customer = repository.GetCustomer(customerId);
allZipCodes = GetAllValidZipCodes();
allZipCodes.Add("11111");
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)