I am trying to create some fakes inside Visual Objects in order to rule out some dependencies while unit testing. Here is some example method that uses CodeBlocks to achieve that:GetFakeOutput function, but just don't know how to do this:
METHOD ValidateTimeString(stringToValidate AS STRING) AS ValidationResultModel CLASS FakeTimeValidator
IF !Empty(FakeValidateTimeStringFunction)
RETURN Eval(FakeValidateTimeStringFunction, stringToValidate)
ENDIF
RETURN SUPER:ValidateTimeString(stringToValidate)
I would like to make this more generic however, so that incoming arguments are passed automatically to subsequent CodeBlocks. Is there some method or code sample I can use to pass incoming params to a codeblock. I woud like to have something like a
METHOD ValidateTimeString(stringToValidate AS STRING) AS ValidationResultModel CLASS FakeTimeValidator
RETURN GetFakeOutput(SELF, GetCurrentMethodName(), GetCurrentMethodValues())
FUNCTION GetCurrentMethodName() AS SYMBOL STRICT
// I already know how to do this!
RETURN AsSymbol(SplitString(ProcName(1), ":", FALSE)[2])
FUNCTION GetCurrentMethodValues() AS ARRAY
// I have no clue what to put here:
LOCAL values := ??? AS ARRAY
RETURN values
FUNCTION GetFakeOutput(instance AS OBJECT, methodToFake AS SYMBOL, inputParams AS ARRAY) AS CODEBLOCK
// I have no clue what to put here:
LOCAL fakeCodeBlock := ??? AS CODEBLOCK
RETURN fakedCodeBlock
Thanks in advance.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 217:23:34 |
Calls: | 6,621 |
Calls today: | 3 |
Files: | 12,171 |
Messages: | 5,317,712 |