0
public with sharing class sccQuestionList {

    Public Integer noOfRecords{get; set;}

    Public Integer size{get;set;}

    Public List<wrapperclass> wrapList{get;set;}

    Public boolean showFlagcheck{get;set;}

    public ApexPages.StandardSetController setCon {


        get{

            if(setCon == null){

                size = 10;

                Id UserId = UserInfo.getUserId();

                string queryString = 'Select Id,Name, Line_Of_Discipline_C__r.Name,Status_C__c,Priority_C__c,Owner.name,Line_Of_Discipline_Focal_Point__r.Name,Site__c,Title_C__c,CreatedDate,CreatedById  from Question__c where CreatedById =: UserId order by CreatedDate DESC';

                setCon = new ApexPages.StandardSetController(Database.getQueryLocator(queryString));

                setCon.setPageSize(size);

                noOfRecords = setCon.getResultSize();

               wrapList = new List<wrapperclass>();



            }

            return setCon;

        }set;

    }



    /*Public Pagination_Demo(){

      wrapList = new List<wrapperclass>();

    } */



    Public List<Question__c> getQuestions(){

        List<Question__c> queList = new List<Question__c>();

        for(Question__c q : (List<Question__c>)setCon.getRecords())

            queList.add(q);

        return queList;

    }



    Public List<wrapperclass> getwrapListshow(){

        List<Question__c> queList = new List<Question__c>();

        wrapList = new List<wrapperclass>();

        for(Question__c q : (List<Question__c>)setCon.getRecords())
        {

            wrapList.add(new wrapperclass(q,false)) ;

            queList.add(q);

        }

        showFlagcheck = true;

        return wrapList ;

    }



    Public class wrapperclass{

         Public Question__c ques{get;set;}

         Public Boolean flagcheck{get;set;}

         Public wrapperclass(Question__c que,boolean checkBox){

           ques = que;

           flagcheck = checkbox;



         }   

    }



    public pageReference refresh() {

        setCon = null;

        getQuestions();

        setCon.setPageNumber(1);

        return null;

    }

    //This is called by action poller in visualforce page

    Integer count = 0;

    public PageReference incrementCounter() {

        count = setCon.getPageNumber();

        return null;

    }


}

Test class:

@isTest
public class testsccQuestionlist {
static testmethod void ssc()
{
    Question__c  Q=new Question__c ();
    insert Q;

    PageReference pageRef = Page.conatactsaved;
    pageRef.getParameters().put('id', String.valueOf(Q.Id));
    Test.setCurrentPage(pageRef);
   sccQuestionList.wrapperclass sccQuestion = new sccQuestionList.wrapperclass(Q);
   //sccQuestion.getQuestions();

}
}
2
  • 1
    What problem have you hit? new sccQuestionList.wrapperclass(Q, false); - you need to provide both constructor arguments - should compile.
    – Keith C
    Dec 30, 2015 at 19:22
  • keerthana - are you asking us to do your work for you? have you looked at guidelines for how to write good testmethods? There are plenty to be found by using a search engine.
    – cropredy
    Dec 30, 2015 at 19:51

1 Answer 1

0

You have to first initialize your wrapper class i.e, provide test values in your test methods and then call the class's methods which you want to test. Are you having any particular issue?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.