+ Start a Discussion
Sai deep 13Sai 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(){
        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
ShirishaShirisha (Salesforce Developers) 
Hi Sai,


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.


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
Sai deep 13Sai deep 13
Thank You Siri for responding, I will look a head with the following link