Created
June 21, 2018 10:02
-
-
Save FishOfPrey/fdf33076e404ebc878b683f6383c67fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FishOfPreySettingsMockProvider implements System.StubProvider { | |
private FishOfPrey_Settings__c testingSettings; | |
public Object handleMethodCall(Object stubbedObject, String stubbedMethodName, | |
Type returnType, List<Type> listOfParamTypes, List<String> listOfParamNames, | |
List<Object> listOfArgs) { | |
string methodName = 'FishOfPreySettingsMockProvider.handleMethodCall() - '; | |
// You can use the method name and return type to determine which method was called. | |
System.debug(LoggingLevel.Debug, methodName + 'Name of stubbed method: ' + stubbedMethodName + | |
'\nReturn type of stubbed method: ' + returnType.getName() + | |
'\n number of parameters passed into the mocked call: ' + listOfArgs.size() + | |
'\n parameter(s) sent into the mocked call: ' + listOfArgs); | |
if(stubbedMethodName == 'getFishOfPreyCustomSettings') { | |
if(testingSettings == null) { | |
testingSettings = new FishOfPrey_Settings__c(); | |
} | |
return testingSettings; | |
} else if (stubbedMethodName == 'setFishOfPreyCustomSettings') { | |
System.debug(methodName + ' ignoring call to ' + stubbedMethodName); | |
return null; | |
} else if (stubbedMethodName == 'upsertSettingsChange') { | |
System.debug(methodName + ' ignoring call to ' + stubbedMethodName); | |
return null; | |
} | |
System.assert(false, methodName + 'unmocked stubbedMethodName: ' + stubbedMethodName); | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment