function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michael MMichael 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;
    }
}
Best Answer chosen by Michael M
Michael MMichael M
This worked:
@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());
    }
}