I am trying to write a test class for my custom controller, but am only getting 30% coverage.
Controller:
public with sharing class topRecordExt {
public List<My_Lobby__c> getRecent2()
{
return [SELECT Id, Title__c, CreatedBy.Name, CreatedDate, VoteTotal__c
FROM My_Lobby__c
WHERE Active_Status__c = 'Active'
order by createdDate desc Limit 10];
}
public List<My_Lobby__c> getMostVoted2()
{
return [SELECT Id, Title__c, CreatedBy.Name, CreatedDate, VoteTotal__c
FROM My_Lobby__c
WHERE Active_Status__c = 'Active'
order by VoteTotal__c desc, CreatedDate desc Limit 10];
}
public List<AggregateResult> top6Contributors1
{
get
{
if (top6Contributors1 == null)
{
top6Contributors1 = [
SELECT CreatedById, CreatedBy.Name name,
count(Id) contributions
FROM My_Lobby__c
GROUP BY CreatedById, CreatedBy.Name
ORDER BY count(CreatedById) desc limit 6
];
}
return top6Contributors1;
}
private set;
}
public topRecordExt() {}
// Code we will invoke on page load.
public PageReference forwardToCustomAuthPage() {
if(UserInfo.getUserType() == 'Guest'){
return new PageReference('MyCenter/MyCenterLogin');
}
else{
return null;
}
}
}
Test Class so far:
@isTest
private class TestTopRecords {
static testMethod void myUnitTest() {
My_Lobby__c a = new Recent2(Title__c = 'Test', Active_Status__c = 'Active');
insert a;
My_Lobby__c c = new MostVoted2(Title__c = 'Test');
insert c;
My_Lobby__c d = new top6Contributors1();
return d;
}
}
Any ideas on how to get to 75%?