The following method has no code coverage because it's only called from a VF page. How to call it in my test class and how to set the variables for the If() statements to be covered?
public PageReference addTraining() {
if (currentQ.Selected_Contacts_Ids_List__c == Null || currentQ.Selected_Contacts_Ids_List__c == '') {
List < training__c > rd = [Select ID FROM training__c WHERE Training_Resource__c =: currentQ.Id];
delete rd;
return null;
}
Training__c[] ts = new Training__c[] {};
if (currentQ.Selected_Contacts_Ids_List__c.containsNone(',')) {
ts.add(new Training__c(Shal__c = currentContacts_CSV, Training_Resource__c = currentQ.Id));
} else {
for (String cId: splitContactIds) {
ts.add(new Training__c(Shal__c = cId, Training_Resource__c = currentQ.Id));
}
}
List < training__c > rd = [Select ID FROM training__c WHERE Training_Resource__c =: currentQ.Id];
delete rd;
insert ts;
init();
return null;
}