You need to sign in to do that
Don't have an account?
Saad Ahmad 27
How to write test class for "Page reference" method? Looking for advise.
My Code is:
Thank you all for your help!
public class AssociateSOExtController { public Quote quote { get; set; } public AssociateSOExtController() { String quoteId = ApexPages.currentPage().getParameters().get('id'); quote = [SELECT Id, Name, Service_Repair__c FROM quote WHERE Id =: quoteId]; } public PageReference associate () { Repair_History__c SORepair = new Repair_History__c ( Id = quote.Service_Repair__c, Quote__c = quote.Id); try { Database.update(SORepair); } catch (Exception error) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Error while associating.' + error.getMessage())); } PageReference page = new PageReference('/' + quote.Id); return page.setRedirect(true); } public PageReference cancel () { PageReference page = new PageReference('/' + quote.Id); return page.setRedirect(true); } }
Thank you all for your help!
All Answers