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
Akhil Katkam 5Akhil Katkam 5 

need test class for these lines

Hi Developer Community , 

i need test class for these 2 lines , can anyone please help me with the solution 
 
@TestVisible

    global ObjectFieldPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }

thansks in advance
Best Answer chosen by Akhil Katkam 5
Suraj Tripathi 47Suraj Tripathi 47

Hi Akhil,

You can take references from the below code.

global class MyCustomPickList extends VisualEditor.DynamicPickList{
    VisualEditor.DesignTimePageContext context;
    VisualEditor.DesignTimePageContext rows;
 
    global MyCustomPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }
    Public static VisualEditor.DesignTimePageContext getRows(String a,String b){
        VisualEditor.DesignTimePageContext context=new  VisualEditor.DesignTimePageContext();
        context.entityName=a;
        context.pageType=b;
        return context;
    }
}

Test Class: 

@isTest
public class DataTest {
    public static testMethod void createContactformCaseTest(){
        VisualEditor.DesignTimePageContext context=new  VisualEditor.DesignTimePageContext();
        context.entityName='Test';
        context.pageType='Data';
        
        test.startTest();
         MyCustomPickList obj=new MyCustomPickList(context);
        test.stopTest();

}
}

Do some need full changes in your code.

Please mark it as the Best Answer if it Helps You.

Thank You

All Answers

Suraj Tripathi 47Suraj Tripathi 47

Hi Akhil,

You can take references from the below code.

global class MyCustomPickList extends VisualEditor.DynamicPickList{
    VisualEditor.DesignTimePageContext context;
    VisualEditor.DesignTimePageContext rows;
 
    global MyCustomPickList(VisualEditor.DesignTimePageContext context) {
        this.rows = getRows(context.pageType, context.entityName);
    }
    Public static VisualEditor.DesignTimePageContext getRows(String a,String b){
        VisualEditor.DesignTimePageContext context=new  VisualEditor.DesignTimePageContext();
        context.entityName=a;
        context.pageType=b;
        return context;
    }
}

Test Class: 

@isTest
public class DataTest {
    public static testMethod void createContactformCaseTest(){
        VisualEditor.DesignTimePageContext context=new  VisualEditor.DesignTimePageContext();
        context.entityName='Test';
        context.pageType='Data';
        
        test.startTest();
         MyCustomPickList obj=new MyCustomPickList(context);
        test.stopTest();

}
}

Do some need full changes in your code.

Please mark it as the Best Answer if it Helps You.

Thank You

This was selected as the best answer
Akhil Katkam 5Akhil Katkam 5
Thank you Suraj , issue has been solved