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
sfdc18sfdc18 

Test Class Code Coverage for Wrapper Class based condition

Hi,

My test class is not covering code inside if loop highlighted below. The If loop is checking count from Wrapper object.
How should I cover the code inside if loop highlighted below.

Apex Class

public class ABC{

Map<Id, List<Services_and_Equipment__c>> mapInstallation2lst_SE = getSErviceEquipmentsInScopeByProduct(pSet_InstallationIds);

if(InstalltionTypeObj.ApprovedSE_Count == mapInstallation2lst_SE.get(InstallationId).size()){

}


    public class InstallationType{
        public Boolean IsMACD;            // If Installation has any S&E with Macd Type 'Move - Add', 'Move - Disconnect', Upgrade, Downgrade Disconnect than it will be true
        public Integer TotalSE_Count;     // Total S&E records for Installation
        public Integer SimpleSE_Count;    // Total S&E records Where Type of Work is Simple
        public Integer ComplexSE_Count;   // Total S&E records Where Type of Work is Complex
        public Integer ApprovedSE_Count;  // Total S&E records Where Stage is Coordinator Approved or Penidng Disconnect
        public Integer MoveAdd_Count;     // Total S&E records Where Stage is Move - Add
        public Integer Add_Count;         // Total S&E records Where Stage is Add
        public InstallationType(){
            IsMACD = false;
            TotalSE_Count = 0;
            SimpleSE_Count = 0;
            ComplexSE_Count = 0;
            ApprovedSE_Count = 0;
            MoveAdd_Count = 0;
        }
    }

}

Thanks
Medhya MahajanMedhya Mahajan
Hi, 

You have to create lets say 1 record and assign to List<Services_and_Equipment__c> and associate it to the InstallationId. Assuming you name this list as serviceEquipmentList :

You can do it like this:
mapInstallation2lst_SE.put(InstallationId, serviceEquipmentList);

Then you can set the value of ApprovedSE_Count variable like this :
ABC.InstalltionTypeObj.ApprovedSE_Count = 1;  // 1 beause we inserted one record 

Let me know if this helps.

Regards
Medhya Mahajan