You need to sign in to do that
Don't have an account?
grandak koy
Create test class for query??
How do I write a test class for this query?
Part of my class:
public with sharing class AccountController {
private Account account;
private list<Requests__c> req;
public id accountId {get;set;}
public List<Account> act {get;set;}
public AccountController(ApexPages.StandardController stdController) {
this.account=(Account)stdController.getRecord();
}
public AccountController(){
}
public List<Requests__c> getOrder(){
req = RequestQueries.RetrieveRequestsForAccount(account.id);
return req;
}
}
My test class so far:
static testMethod void testMethodForAccount()
{
Account act = new Account();
insert act;
Request__c req = new Request__c();
req.Account__c = act.id;
insert req;
Test.startTest();
PageReference pageRef = Page.AccountsHomePage;
pageRef.getParameters().put('id', String.valueOf(act.id));
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('id','act.id');
ApexPages.StandardController sc = new ApexPages.standardController(acc1);
AccountController a = new AccountController(sc);
AccountController Anull = new AccountController(new ApexPages.StandardController(act));
Test.stopTest();
}
}
Part of my class:
public with sharing class AccountController {
private Account account;
private list<Requests__c> req;
public id accountId {get;set;}
public List<Account> act {get;set;}
public AccountController(ApexPages.StandardController stdController) {
this.account=(Account)stdController.getRecord();
}
public AccountController(){
}
public List<Requests__c> getOrder(){
req = RequestQueries.RetrieveRequestsForAccount(account.id);
return req;
}
}
My test class so far:
static testMethod void testMethodForAccount()
{
Account act = new Account();
insert act;
Request__c req = new Request__c();
req.Account__c = act.id;
insert req;
Test.startTest();
PageReference pageRef = Page.AccountsHomePage;
pageRef.getParameters().put('id', String.valueOf(act.id));
Test.setCurrentPage(pageRef);
ApexPages.currentPage().getParameters().put('id','act.id');
ApexPages.StandardController sc = new ApexPages.standardController(acc1);
AccountController a = new AccountController(sc);
AccountController Anull = new AccountController(new ApexPages.StandardController(act));
Test.stopTest();
}
}
All Answers
public PageReference SaveReq(){
insert req;
PageReference Page = new PageReference('/apex/AccountInformationWithRequests?id='+Req.Account__c);
Page.setRedirect(true);
return Page;
accCon.SaveReq() ;