lstw.add(new wrapper(acc[i].name,acc[i].id,con[i].LastName,con[i].id));
and how can I check that the Id's of Account and Contact are truly returned?
Thanks in advance
My wrapper class:
public class WR1 {
List <Account> acc = new List <Account>();
List <Contact> con = new List <Contact>();
public List <wrapper> lstw = new List <wrapper>();
public List <wrapper> getLstwrapperIntString(){
acc = [select name, id from Account];
con = [select LastName, id from Contact];
system.debug(acc.size());
for (Integer i=0;i<acc.size();i++){
lstw.add(new wrapper(acc[i].name,acc[i].id,con[i].LastName,con[i].id));
}
return lstw;
}
public class wrapper{
public String AName{get;set;}
public STring AId{get;set;}
public String CLastName{get;set;}
public String CId{get;set;}
public wrapper (String AName, String AId, String CLastName, String CId){
this.AName=AName;
this.AId=AId;
this.CLastName=CLastName;
this.CId=CId;
}
}
}
My test class:
@isTest
public class WR1test {
static testMethod void WR1tst(){
List <Account> acc = new List <Account>();
List <Contact> con = new List <Contact>();
acc = [select name, id from Account where id='0010Y000002Si62QAC'];
con = [select LastName, id from Contact where id='0030Y000001oQp1QAE'];
String AName;
String AId;
String CLastName;
String CId;
WR1 testWR1 = new WR1();
testWR1.getLstwrapperIntString();
WR1.wrapper testwrapper=new WR1.wrapper(AName,AId,CLastName,CId);
}
}