You need to sign in to do that
Don't have an account?
Covering Sort Method in test class
Can somebody pls tell me hoe can I cobe the sort method in the test class;
public List<SelectOption> Sort(List<SelectOption> lstToSort)
{
System.Debug('Original List: ' + lstToSort);
List<SelectOption> returnList = new List<SelectOption>();
try
{
// Convert SelectOption list To String List
List<String> convertedList = new List<String>();
for(SelectOption opt: lstToSort)
{
convertedList.add(opt.getLabel());
}
convertedList = sortList(convertedList);
System.Debug('Convert and Sorted: ' + convertedList);
// Convert String List to SelectOption list
for(String strOpt: convertedList)
{
returnList.add(new SelectOption(strOpt,strOpt));
}
System.Debug('Returning: ' + returnList);
}
catch(Exception exp)
{
System.Debug('Exception in Sort(): ' + exp.getMessage());
}
return returnList;
}
Call the sort method along with OptionList as a argument from the test class.