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

Help with test class code
HI Friends,
I am Newbie in writing Test classes, Please do help with test code for this apex class.
public with sharing class AccountController {
public AccountController() {
}
public AccountController(ApexPages.StandardController controller) {
}
Public String selectedTab {get; set;}
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
User U;
public ApexPages.StandardSetController setCon {
get{
if(setCon == null){
size = 25;
U = [select id,Phone,name from User WHERE ID =:userinfo.getUserId()];
string queryString = 'Select Name, Rating,Phone from Account order by Name';
setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id,Name,Phone from Account Where Phone =:U.Phone AND Rating ='Hot']));
setCon.setPageSize(size);
noOfRecords = setCon.getResultSize();
}
return setCon;
}set;
}
Public List<Account> getAccounts(){
List<Account> accList = new List<Account>();
for(Account a : (List<Account>)setCon.getRecords())
accList.add(a);
return accList;
}
public pageReference refresh() {
setCon = null;
getAccounts();
setCon.setPageNumber(1);
return null;
}
}
I am Newbie in writing Test classes, Please do help with test code for this apex class.
public with sharing class AccountController {
public AccountController() {
}
public AccountController(ApexPages.StandardController controller) {
}
Public String selectedTab {get; set;}
Public Integer noOfRecords{get; set;}
Public Integer size{get;set;}
User U;
public ApexPages.StandardSetController setCon {
get{
if(setCon == null){
size = 25;
U = [select id,Phone,name from User WHERE ID =:userinfo.getUserId()];
string queryString = 'Select Name, Rating,Phone from Account order by Name';
setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT id,Name,Phone from Account Where Phone =:U.Phone AND Rating ='Hot']));
setCon.setPageSize(size);
noOfRecords = setCon.getResultSize();
}
return setCon;
}set;
}
Public List<Account> getAccounts(){
List<Account> accList = new List<Account>();
for(Account a : (List<Account>)setCon.getRecords())
accList.add(a);
return accList;
}
public pageReference refresh() {
setCon = null;
getAccounts();
setCon.setPageNumber(1);
return null;
}
}
--
Abhi