+ Start a Discussion
stevewardsteveward 

Extended Controller Class Test

Apologies first of all as I am very new to apex but I am struggling to create a test to ensure rows are returned from a test header.id  

 

This is the class 

 

public class SDW_NonRechargeable_Line_Items {

private SFDC_Expense_Header__c header;

private ApexPages.StandardController controller;

 

public SDW_NonRechargeable_Line_Items(ApexPages.StandardController stdController) {

controller = stdController;

header = (SFDC_Expense_Header__c)controller.getRecord();

}

 

public List<Expense_Line_Item__c> NRLineItems {get {

if(header == null){

return new List<Expense_Line_Item__c>();

 

}

List <Expense_Line_Item__c> Non_Rechargeable_Line_Items = [

Select

Name,

Expenditure_Type_Non_Rechargeable__c,

Description__c,

Date__c,

Amount_net__c,

Amount_Gross__c,

CurrencyIsoCode

from Expense_Line_Item__c

where Expense_Report__c = :header.Id order by Date__c];

return Non_Rechargeable_Line_Items;

 

}

set;

}

}

 

 

My test class so far...

 

 

@isTest

private class ExpensesTestSuite {

 

 

static testMethod void run_SDW_NonRechargeable_Line_Items_Tests() {

 

// TO DO: implement unit test

 

List <Expense_Line_Item__c> Non_Rechargeable_Line_Items = new list<Expense_Line_Item__c>();

 

ApexPages.StandardSetController ssc = new

ApexPages.StandardSetController(Non_Rechargeable_Line_Items);

 

 

// Validate bulk SELECT

System.debug('Testing SELECT List return');

 

 

 

//

 

 

}

}

 

Where do I go from here, the examples I see on the forum don't seem to be helping me test for a select as opposed to updates or inserts.

 

Help gratefully appreciated.

 

Regards,

Steve 

 

jeffdonthemicjeffdonthemic

Steve,

 

Have you looked at the following:

 

An Introduction to Apex Code Test Methods 

 

Testing Custom Controllers and Controller Extensions 

 

Jeff Douglas

Appirio

http://blog.jeffdouglas.com 

stevewardsteveward
Yes - spent 2 days!! but guess I am jumping in at the deep end as usual. I am under pressure on another project so will have to leave until the weekend.   Steve