+ Start a Discussion

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
private class BHTest {
    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);