You need to sign in to do that
Don't have an account?
B_k
Test code for the attachment class!!
I'm facing problem to how to write test code for the attachment class.
Apex Class
public class CaseControllerExt {
private final Case acase;
public Blob afile {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
public CaseControllerExt(ApexPages.StandardController stdController){
this.acase=(Case)stdController.getRecord();
acase.Status = 'New';
acase.Origin = 'IT Request Form';
}
public PageReference createCaseWithAttachment() {
try{
insert(acase);
}catch(System.DMLException e){
ApexPages.addMessages(e);
}
if(afile!=null){
Attachment attach=new Attachment();
attach.Body=afile;
attach.Name=filename;
attach.ContentType=contentType;
attach.ParentID=acase.id;
try {
insert(attach);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
}
PageReference p = Page.Confirmpage;
p.setRedirect(true);
return p;
}
}
Please provide solution for that.
Apex Class
public class CaseControllerExt {
private final Case acase;
public Blob afile {get; set;}
public String contentType {get; set;}
public String fileName {get; set;}
public CaseControllerExt(ApexPages.StandardController stdController){
this.acase=(Case)stdController.getRecord();
acase.Status = 'New';
acase.Origin = 'IT Request Form';
}
public PageReference createCaseWithAttachment() {
try{
insert(acase);
}catch(System.DMLException e){
ApexPages.addMessages(e);
}
if(afile!=null){
Attachment attach=new Attachment();
attach.Body=afile;
attach.Name=filename;
attach.ContentType=contentType;
attach.ParentID=acase.id;
try {
insert(attach);
} catch(System.DMLException e) {
ApexPages.addMessages(e);
return null;
}
}
PageReference p = Page.Confirmpage;
p.setRedirect(true);
return p;
}
}
Please provide solution for that.
You need to use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
You need to use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
i got these errors
Variable does not exist: caseList
Variable does not exist: test
Variable does not exist: ParentID