so I have
/// <summary>
///We cannot sell to someone who's address postcode is Channel Islands = GY
/// or Isle of Man = IM.
/// So there are three possibilities... an unclear channel islands I.D. needs a pop up, an error or invalid country needs a pop up and a good match can display policyholder
///
/// </summary>
public void ValidateAddressCanPurchaseInsurance(PolicyHolder p)
{
if (p == null) {DisplayErrorPopup(@"Could not check address for this person - Dang!"); return;}
var countryResult = IdentifyUnavailableAddresses(p);
if (countryResult == UnavailableAddressMatch.UnmatchedChannelIslands) {DisplayErrorPopup("Couldn't determine whether this Channel Islands resident is Jersey or Guernsey based... fix postcode and retry application"); return;}
if (countryResult == UnavailableAddressMatch.Guernsey || countryResult == UnavailableAddressMatch.IsleOfMan) { DisplayErrorPopup(countryResult); return;}
if (countryResult == UnavailableAddressMatch.None) { DisplayPolicyHolder(p); return; }
DisplayErrorPopup(String.Format("Something very odd has gone on while trying to validate the address of this person! {0}",p.MembershipNumber));
}
Which I can’t really test… I can obviously test IdentifyUnavailableAddresses() and do but I’d like to pass a set of policyHolders to this method and see that it behaves as I expect.
Display Error Popup will take an UnavailableAddressMatch enum and format a pop-up message appropriately or take a string and put it in a pop-up
This method lives in a class that determines the behaviour of a Windows Form…
ValidateAddressCanPurchaseInsuranceis a business layer method.DisplayErrorPopupis a UI thing. They do not belong in the same class.Putting
DisplayErrorPopupin another class makes it possible to put a mock object in your unit test and check whetherDisplayErrorPopupis called.