You need to sign in to do that
Don't have an account?
JHA
How to write test method?
public class MileageUtil { |
Anyone can plz help me out to write test method for above code?
Thanks.
public class MileageUtil { static final Integer MAX_MILES_PER_DAY = 500; public static void areMilesAllowed(accelerantforce__Mileage__c[] miles) { Double totalMiles = 0; totalMiles = [select sum(miles__c) from accelerantforce__Mileage__c where Date__c = TODAY AND accelerantforce__Mileage__C.createdById = :UserInfo.getUserId() ]; for (accelerantforce__Mileage__c m:miles) totalMiles += m.miles__c; if(totalMiles > MAX_MILES_PER_DAY) m.addError('Mileage request exceeds daily limit: ' + MAX_MILES_PER_DAY); }