You need to sign in to do that
Don't have an account?
Michael M
Help with test code for simple controller
I have a simple controller, but am not sure how to write a test class for it. Can anyone please help?
Here is the controller:
public class LeadsInfoController {
//capture the user id
public ID salesRepID {get; set;}
public List<Lead_Ownership__c> ClsInfo = new List<Lead_Ownership__c>();
public List<Lead_Ownership__c> getInactiveLeads() {
ClsInfo = [select Source__c, Facility_Region__c, Lead_Owner__r.name from Lead_Ownership__c where ownerId =: salesRepID];
return ClsInfo;
}
}
Here is the controller:
public class LeadsInfoController {
//capture the user id
public ID salesRepID {get; set;}
public List<Lead_Ownership__c> ClsInfo = new List<Lead_Ownership__c>();
public List<Lead_Ownership__c> getInactiveLeads() {
ClsInfo = [select Source__c, Facility_Region__c, Lead_Owner__r.name from Lead_Ownership__c where ownerId =: salesRepID];
return ClsInfo;
}
}
@isTest
public class LeadsInfoControllerTest {
@isTest
static void TestLeadsInfoController(){
List<Lead_Ownership__c> listpba = new List<Lead_Ownership__c> ();
Lead_Ownership__c TestListing = new Lead_Ownership__c();
testListing.source__c='BookaTour';
testListing.facility_region__c='Downstate';
listpba.add(TestListing);
insert listpba;
Test.startTest();
LeadsInfoController pr = new LeadsInfoController();
List<Lead_Ownership__c> mylist = pr.getInactiveLeads();
Test.stopTest();
// system.assertEquals(1, mylist.size());
}
}