You need to sign in to do that
Don't have an account?
Sai deep 13
Hi every one Can you please help to write test class for this apex class , Here is my apex class .its urgent please hrelp
public class PatientDemo1_Class {
public string fileName{get;set;}
public Blob fileBody{get;set;}
Account acc = new Account();
public Account getacc(){
acc.Name='PRG';
return acc;
}
public pagereference Saveaccount(){
insert acc;
Attachment myAttachment = new Attachment();
myAttachment.Body = fileBody;
myAttachment.Name = fileName;
myAttachment.ParentId = Acc.Id;
insert myAttachment;
return page.Demo1Thanks;
}
}
Thanks and regards
Saideep
public string fileName{get;set;}
public Blob fileBody{get;set;}
Account acc = new Account();
public Account getacc(){
acc.Name='PRG';
return acc;
}
public pagereference Saveaccount(){
insert acc;
Attachment myAttachment = new Attachment();
myAttachment.Body = fileBody;
myAttachment.Name = fileName;
myAttachment.ParentId = Acc.Id;
insert myAttachment;
return page.Demo1Thanks;
}
}
Thanks and regards
Saideep
Greetings!
Can you please check the below sample code to insert the Attachment record in Test class and also,please insert the Account record before inserting Attachment to get the AccountId.
http://nmreddy1.blogspot.com/2013/10/writing-apex-test-method-for-insert.html
Kindly let me know if it helps you and close your query by marking it as best answer so that it can help others in the future.
Warm Regards,
Shirisha Pathuri