function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bharath kuamarbharath kuamar 

Test Class

Please help me with this test class below as follows,

 

public class DonorProfileController
{
    public String contactId {get;set;}
    public Contact donorObj {get;set;}
    
    public DonorProfileController() {
        User oUser = [Select Id, ContactId From User Where Id=:UserInfo.getUserId()];
            contactId = oUser.contactId;
            donorObj = [Select FirstName,LastName,BirthDate,Description,Email,Phone,Mobilephone,Fax From Contact Where Id=:contactId];

    }
   
    public String firstname{ get; set;}
    
    public String lastname{ get; set; }
    
    public Date birthdate{ get; set; }

    public String description { get; set; }

    public String email { get; set; }

    public String phone { get; set; }

    public String homephone { get; set; }

    public String fax { get; set; }

    public String mobilephone { get; set; }

     public PageReference saveAction()
    {
    System.debug('saveAction()');
        
//        MyProfile__c profile=[Select Name,First_Name__c,BirthDate__c,Description__c,Fax__c,Email__c,Phone__c from MyProfile__c Where Id=:contactId ];
        MyProfile__c profile=new MyProfile__c();
        profile.Name = this.lastname;
        profile.First_Name__c = this.firstname;
        profile.BirthDate__c = this.birthdate;
        profile.Description__c=this.description;
        profile.Email__c=this.email;
        profile.Phone__c=this.phone;
        profile.Fax__c=this.fax;
        profile.Mobile__c=this.mobilephone;
        insert profile;
        return null;
        
      /*  Contact donorObj = [Select FirstName,LastName,BirthDate,Description,Email,Phone,Mobilephone,Fax From Contact Where Id=:profile.Id];
        donorObj.LastName = profile.Name;
        donorObj.FirstName = profile.First_Name__c;
        donorObj.BirthDate = profile.Birthdate__c;
        donorObj.Description=profile.Description__c;
        donorObj.Email=profile.Email__c;
        donorObj.Phone=profile.Phone__c;
        donorObj.Fax=profile.Fax__c;
        donorObj.Mobilephone=profile.Mobile__C;
        update donorObj;
        */
        
        
       }
           
          /*      
            if (pageRef == null) {
                pageRef = Page.DonorProfile;
            }
            pageRef.setRedirect(true);
            return pageRef;
            */
            
            
            //test methods written for the class DonorProfileController
            
 
 
          
          
 
}

 

thanks in advance