I'm writing a test class right now, and I'm calling a method in the class that I am wanting to test. The method in the main class that I'm wanting to test is called getTruckerAvailability(). Here is what it looks like.
@auraEnabled
public static List<Truck_Availability__c> getTruckerAvailability(String[] bundleids, String region, Decimal arr){
//Code in here...
return ...
}
The issue I'm having is I don't know the syntax for passing in bundles to the string array. Bundle__c is an object in my org, and there are bundle records. So the array in that method above is receiving bundle record Ids as strings.
In my test class, what is the syntax for passing in actual ids that are strings? Here is what I have.
@IsTest static void testTruckAvailability(){
//Create new bundle 1
Bundle__c b = new Bundle__c();
b.Name = 'Test bundle';
b.Active__c = TRUE;
insert b;
//Create new bundle
Bundle__c b2 = new Bundle__c();
b2.Name = 'Test bundle';
b2.Active__c = TRUE;
insert b2;
List<Truck_Availability__c> newClassCall = myClass.getTruckAvailability( {b.Id, b2.Id}, 'North America', 12000.00);
}
I get errors when I format the array of strings as {b.Id, b2.Id}. I've tried to create a 2 new string variables and set the ids to those string variables with String.ValueOf(b.Id) or String.ValueOf(b2.Id). I just can't find anywhere online what the correct syntax would be for passing in an array of strings to a method call in a test class.