4

I created a controller which looks like this

public with sharing class EventRegistrationController {

    // A CONTROLLER FUNCTION
    // FUNCTION RETURNS A LIST OF cSession
     public List<cSession> getSessions() {

          //DO STUFF

     }

   //A PUBLIC CLASS WITHIN CONTROLLER
   @TestVisible public class cSession 
    {
        public Session__c con {get; set;}
        public Boolean selected {get; set;}

        //This is the contructor method. 
        public cSession(Session__c c) {

            con = c;
            selected = false;
        }
    }
 }

I need to write a test code for the controller, how can I create a list of cSession and call getSession function?

1 Answer 1

6

You can create a new cSession in the following way:

EventRegistrationController.cSession cSession = new EventRegistrationController.cSession(c);

You can call the getSessions method using:

EventRegistrationController controller = new EventRegistrationController();
List<EventRegistrationController.cSession> controller.getSessions();
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .