You need to sign in to do that
Don't have an account?

test class for wrapper
hi guys i am trying to write a test class for wrapper class
public class AccountSelectClassController {
public list<account> selectedAccounts { get; set; }
public list<wrapaccount>wrapAccountList { get; set; }
public AccountSelectClassController(){
if(wrapAccountList == null) {
wrapAccountList = new List<wrapAccount>();
for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
// As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
wrapAccountList.add(new wrapAccount(a));
}
}
}
public void processSelected() {
selectedAccounts = new List<Account>();
for(wrapAccount wrapAccountObj : wrapAccountList) {
if(wrapAccountObj.selected == true) {
selectedAccounts.add(wrapAccountObj.acc);
}
}
}
public class wrapaccount
{
public account acc{get;set;}
public boolean selected{get;set;}
public wrapaccount(account a)
{
acc=a;
selected=false;
}
}
}
can u plz guide me to write a test class
@istest
public class AccountSelectClassControllertest
{
static testmethod void wraptest()
{
account ac=new account(name='hari',billingcity='hyderabad',phone='9700956194');
AccountSelectClassController.wrapaccount acw= new AccountSelectClassController.wrapaccount(ac);
acw.compareTo(acw);
}
}
public class AccountSelectClassController {
public list<account> selectedAccounts { get; set; }
public list<wrapaccount>wrapAccountList { get; set; }
public AccountSelectClassController(){
if(wrapAccountList == null) {
wrapAccountList = new List<wrapAccount>();
for(Account a: [select Id, Name,BillingState, Website, Phone from Account limit 10]) {
// As each Account is processed we create a new wrapAccount object and add it to the wrapAccountList
wrapAccountList.add(new wrapAccount(a));
}
}
}
public void processSelected() {
selectedAccounts = new List<Account>();
for(wrapAccount wrapAccountObj : wrapAccountList) {
if(wrapAccountObj.selected == true) {
selectedAccounts.add(wrapAccountObj.acc);
}
}
}
public class wrapaccount
{
public account acc{get;set;}
public boolean selected{get;set;}
public wrapaccount(account a)
{
acc=a;
selected=false;
}
}
}
can u plz guide me to write a test class
@istest
public class AccountSelectClassControllertest
{
static testmethod void wraptest()
{
account ac=new account(name='hari',billingcity='hyderabad',phone='9700956194');
AccountSelectClassController.wrapaccount acw= new AccountSelectClassController.wrapaccount(ac);
acw.compareTo(acw);
}
}
Hope below code will help you.
Please mark it as solution if it helps you.
All Answers
Hope below code will help you.
Please mark it as solution if it helps you.