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
sgsssgss 

Map and Test Case for it.

Can anyone provide code and Tes Class for this?

 Prepare the following map structures :
a. Account Name as key and AccountId as value.
b. Account Id as key and entire Account object as value.
Raj VakatiRaj Vakati
@IsTest
private class BHTest {
    @isTest
    static void TestBH()
    {
        List<Account> accs = new List<Account>();
        for(Integer i =0 ;i <10;i++){
            accs.add( new Account(Name ='TEst'+i));
        }
        insert accs ;
        BH b = new BH();
    }
    
}
 
public class BH {
    public Map<String,String> mapOfNameAndId = new Map<String,String>() ;
    public Map<String,Account> mapOfIdAndObj = new Map<String,Account>() ;
    
    public BH(){
        List<Account> acc =[Select Id , Name from Account] ;
        for(Account a : acc){
            mapOfNameAndId.put(a.Name , a.Id) ;
            mapOfIdAndObj.put(a.Id ,a);
        }
        
        
    }
}