+ Start a Discussion

Test Code for Visualforce Email Component Controller

Hi guys, 

I can't seem to get anywhere with the test code for this simple table I put within a Visualforce Email Template:

public  class GetOpportunityProducts
    public Id OpportunityId {get;set;}
      public List<OpportunityLineItem> GetLineItems()
        List<OpportunityLineItem> line;
        line= [SELECT Quantity,Product2.Name,TotalPrice,Net_Value__c,CurrencyISOCODE,UnitPrice FROM OpportunityLineItem WHERE OpportunityId=: OpportunityId];
        return line;
Small Table within VS Email
<c:DisplayOppLineItems OppId="{!relatedTo.Id}" /><br/><br/>          

Best Answer chosen by LaurenP6777
Prateek Singh SengarPrateek Singh Sengar
public class testCustomEmail

public static void testEmailComp()
          //Create dummy product record
          //Create dummy opportunity
          //Create dummy opplineitem

           GetOpportunityProducts obj = new GetOpportunityProducts();



Please create dummy test record for product, opportunity and opp line item where the comments is. Hope this helps.