Skip to main content
Post Closed as "Not suitable for this site" by martin, Tushar Sharma, superfell, Adrian Larson, cropredy

public with sharing class DisplayAttachAccountController {

public with sharing class DisplayAttachAccountController {

    

    private String parentId {
        set;
        get;
    }
    public List < Attachment > attList {
        get;
        set;
    }

    public DisplayAttachAccountController(ApexPages.StandardController stdController) {
        this.parentId = stdController.getId();
        System.debug('&&&&' + parentId);
        attList = [SELECT ParentId, Name, Id, ContentType, BodyLength FROM Attachment
            WHERE ParentId in (Select Id from opportunity where accountId =: this.ParentId)
        ];
    }

}

@isTest public class AttachTesting { static testmethod void validateAttach(){ Account obj = new Account(Name ='Test'); insert obj;


}

@isTest
public class AttachTesting {
    static testmethod void validateAttach(){
        Account obj = new Account(Name ='Test');
         insert obj;

        //apexpages.currentpage().getparameters().put('id' , yourID);

        ApexPages.StandardController stdController;
      DisplayProfilePictureController conAttach= new DisplayProfilePictureController(stdController);  

    }
}

}

public with sharing class DisplayAttachAccountController {

private String parentId {
    set;
    get;
}
public List < Attachment > attList {
    get;
    set;
}

public DisplayAttachAccountController(ApexPages.StandardController stdController) {
    this.parentId = stdController.getId();
    System.debug('&&&&' + parentId);
    attList = [SELECT ParentId, Name, Id, ContentType, BodyLength FROM Attachment
        WHERE ParentId in (Select Id from opportunity where accountId =: this.ParentId)
    ];
}

}

@isTest public class AttachTesting { static testmethod void validateAttach(){ Account obj = new Account(Name ='Test'); insert obj;

    //apexpages.currentpage().getparameters().put('id' , yourID);

    ApexPages.StandardController stdController;
  DisplayProfilePictureController conAttach= new DisplayProfilePictureController(stdController);  

}

}

public with sharing class DisplayAttachAccountController {

    

    private String parentId {
        set;
        get;
    }
    public List < Attachment > attList {
        get;
        set;
    }

    public DisplayAttachAccountController(ApexPages.StandardController stdController) {
        this.parentId = stdController.getId();
        System.debug('&&&&' + parentId);
        attList = [SELECT ParentId, Name, Id, ContentType, BodyLength FROM Attachment
            WHERE ParentId in (Select Id from opportunity where accountId =: this.ParentId)
        ];
    }

}

@isTest
public class AttachTesting {
    static testmethod void validateAttach(){
        Account obj = new Account(Name ='Test');
         insert obj;

        //apexpages.currentpage().getparameters().put('id' , yourID);

        ApexPages.StandardController stdController;
      DisplayProfilePictureController conAttach= new DisplayProfilePictureController(stdController);  

    }
}
Source Link

How to write test class of the following apex class

public with sharing class DisplayAttachAccountController {

private String parentId {
    set;
    get;
}
public List < Attachment > attList {
    get;
    set;
}

public DisplayAttachAccountController(ApexPages.StandardController stdController) {
    this.parentId = stdController.getId();
    System.debug('&&&&' + parentId);
    attList = [SELECT ParentId, Name, Id, ContentType, BodyLength FROM Attachment
        WHERE ParentId in (Select Id from opportunity where accountId =: this.ParentId)
    ];
}

}

@isTest public class AttachTesting { static testmethod void validateAttach(){ Account obj = new Account(Name ='Test'); insert obj;

    //apexpages.currentpage().getparameters().put('id' , yourID);

    ApexPages.StandardController stdController;
  DisplayProfilePictureController conAttach= new DisplayProfilePictureController(stdController);  

}

}