You need to sign in to do that
Don't have an account?
Request Help for the Apex Code test
public with sharing class extLogACase
{
private final Case webCase;
private final Case twebCase;
public extLogACase(ApexPages.StandardController stdController)
{
webCase= (Case)stdController.getRecord();
webCase.put('Origin', 'Web');
webCase.put('Case_Account__c', ApexPages.currentPage().getParameters().get('CurrentAccount'));
webCase.put('Case_Reported_By__c', ApexPages.currentPage().getParameters().get('LoggedInUser'));
}
public PageReference logCase()
{
try {
insert(webCase);
}
catch(System.DMLException e)
{ ApexPages.addMessages(e);
return null;
}
PageReference p = Page.ThankYou;
p.setRedirect(true);
return p;
}
public PageReference resetCase()
{ webCase.put('Subject', 'S');
webCase.put('Description', 'D');
PageReference p1 = Page.My_Cases;
p1.setRedirect(true);
return p1;
}
}
try this :
static testMethod void main() {
Account a = new Account(Name = 'test');
insert a;
Case c = new Case();
system.currentPageReference().getParameters().put('CurrentAccount', a.Id);
system.currentPageReference().getParameters().put('LoggedInUser', UserInfo.getUserId());
ApexPages.Standardcontroller obj = new Apexpages.Standardcontroller(c);
extLogCase extLogCaseObj = new extLogCase (obj);
extLogCaseObj.logCase();
extLogCaseObj.resetCase();
}
for more information follow:
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
All Answers
try this :
static testMethod void main() {
Account a = new Account(Name = 'test');
insert a;
Case c = new Case();
system.currentPageReference().getParameters().put('CurrentAccount', a.Id);
system.currentPageReference().getParameters().put('LoggedInUser', UserInfo.getUserId());
ApexPages.Standardcontroller obj = new Apexpages.Standardcontroller(c);
extLogCase extLogCaseObj = new extLogCase (obj);
extLogCaseObj.logCase();
extLogCaseObj.resetCase();
}
for more information follow:
http://wiki.developerforce.com/page/An_Introduction_to_Apex_Code_Test_Methods
Thanks