I have a controller that queries users to be selected in a vf page. I want to write a test class to test the code. The problem is I can't seem to populate the selection in my test so that it goes through the code.
The controller grabs the options:
public void fetchusers() {
if (selectedAttendeeType=='Search Account Team'){
Id accountId = account.Id;
for (User npdUser: [SELECT Id, Name FROM User WHERE IsActive=true AND Id IN (SELECT User__c FROM NPD_Account_Team__c WHERE Account__c = :accountId OR Parent_Account__c = :accountId) ORDER BY Name ASC LIMIT 1000]){
possibleNPDAttendees.add(new SelectOption(npdUser.Id, npdUser.name));
}
}
The vf page the user selects the value:
<apex:outputPanel rendered="{!IF(account.RecordType.DeveloperName!='Practice_Account', 'true', 'false')}">
<input type="radio" id="accountTeamList" name="Attendee" value="Search Account Team" checked="true" onclick="setSelectedSearch(this.value);"/>
<b><label for="accountTeamList">Search Account Team</label></b><br/>
<input type="radio" id="allNPDList" name="Attendee" value="Search All NPD" onclick="setSelectedSearch(this.value);"/>
<b><label for="allNPDList">Search All NPD</label></b>
...
<c:SL_SelectBoxes id="attendeeSelection" leftOption="{!possibleNPDAttendees}"
rightOption="{!NPDAttendees}"
size="14"
width="350px"
height="100px"/>
In my test class tha I am rebuilding from an existing test the developer just called the methods and didn't actually test anything.
....
callReport.selectedAttendeeType = 'Search Account Team';
callReport.fetchusers();
I have some users created in the test class, so I thought of doing the following to grab my user created in test and assign it to the select option so it would mimic being selected by the user.
callReport.npdattendees.add(user1.id, user1.LastName);
However, I get this error:
Method does not exist or incorrect signature: [List].add(Id, String)
If I just add the Id I get:
Incompatible element type Id for collection of System.SelectOption
How can one test adding a selection value?
SelectOption
(s) to theList
.