I have the following extension class that I'm using to build a visual force page. It is intended to display a filtered list of Campaign History, rather than the existing related list. It works. That's not the question.
//VF extension, designed to extend the Contact standard controller to display a filtered campaign history list
public class CampaignHistoryExtension {
//this is the Contact ID variable passed by the standard controller
private ID thisContactID;
//List variable of campaign member records to return to the page as the sorted campaign list
private transient List<campaignMember> campaignMemberRecords;
//Constructor to extend the standard Contact controller a\@param controller
//@param the standardController object constructed by specifying the standardControler attribute in an apex:page
public CampaignHistoryExtension(ApexPages.StandardController controller) {
thisContactID = controller.getId();
refreshCampaignMemberRecords();
}
//@return the list of Campaign Member records to present as the campaign history
public LIST <CampaignMember> getCampaignMemberRecords(){
return campaignMemberRecords;
}
//refresh the list of campaign member records presented as teh contact campaign history by qurying the db using known properties as filter
private void refreshCampaignMemberRecords(){
campaignMemberRecords = [
SELECT ID, CampaignID, Campaign.Name, Campaign.enddate, ContactID, Contact.Name, Status,
Campaign.Type, campaign.Display_Campaign_on_Contact__c, LastModifiedDate
FROM CampaignMember
WHERE ContactID = :thisContactID
AND Campaign.Display_Campaign_on_Contact__c=TRUE
ORDER BY Campaign.Name];
}
}
The question is, I now am working to create a test class to get coverage. My assumption is that I would need to create a Contact, a Campaign, and a Campaign Member record, and then check if the campaignMemberRecords query returns an appropriate number (1, in this example) of records. I could expand the datasets to have more Contacts and more Campaign Members, but I'm wondering if there's something more I should be testing, or is that all I'l likely need to cover?
Am I on the right track? Am I missing something?