I've got a Visualforce component with a custom controller that I inherited and need to write a test class for. I am having difficulty getting the one method it contains to execute. I have called the VF page containing the component, but I can't work out how to make it then call the component to test the controller's behaviour.
This previous question and answer gave me some guidance, but I am still struggling with it.
Controller
public with sharing class TypeControllerNew2 {
public class CaseCharges {
public Integer count {get; set;}
public String typ {get; set; }
CaseCharges(String typ, Integer count) {
this.count = count;
this.typ = typ;
}
}
}
VF Component
<apex:page docType="html-5.0" showHeader="false" sidebar="false" cache="false" controller="TypeControllerNew2" standardStylesheets="false" >
<body>
<outputPanel style="padding: 15px;">
<a href="/apex/CaseList?fcf=00B21000000UI5I" class="alert-link"> Estimate of Non-Primary Charges</a>
<apex:chart height="380" width="400" data="{!CaseCharges}">
<apex:legend position="right"/>
<apex:axis type="Numeric" position="bottom" fields="count" title="Case Record Count" minimum="0" maximum="10" />
<apex:axis type="Category" position="left" fields="typ" title="Case Type" />
<apex:barSeries title="In Progress Cases" orientation="horizontal" gutter="10" axis="bottom" xField="count" yField="typ" colorsProgressWithinSeries="true" colorset="red, green, yellow, black, white, orange" >
<apex:chartTips height="20" width="120" />
</apex:barSeries>
</apex:chart>
<apex:dataTable value="{!CaseCharges}" var="ty">
<apex:column headerValue="Case Type" value="{!ty.typ}"/>
<apex:column headerValue="Number of Cases" value="{!ty.count}"/>
</apex:dataTable>
</outputPanel>
</body>
Test class
@isTest (seeAllData = true)
public class TypeControllerNew2_Test {
static testMethod void typeController2Test(){
PageReference graph2Page = Page.AWSHome;
Test.setCurrentPage(graph2Page);
TypeControllerNew2 tcNew2Test = new TypeControllerNew2();
tcNew2Test.getCaseCharges();
}
}