0

I have ONE class. There is a method (let's call it Process(data)) that when called can branch off and call 1 of x functions (let's say ProcessA(), ProcessB(), ProcessC()) of that SAME class based on some parameters I pass in. How can I verify a certain function got called that I'm expecting based on the parameter data I enter?

All the examples I've seen do this on a mocked object passed into another object, but I need this on the same, one, object.

[EDIT] This is different from the question someone marked as Duplicate because this has nothing to do with a base class. Inside this class I have a dictionary of function pointers where the key is a value that is passed on from the config data so it branches off and I need to test that's all working correctly and the correct function is being called based on that config data. This is different than the possible duplicate.

user441521
  • 6,942
  • 23
  • 88
  • 160
  • 2
    A public method calling different private methods based on a parameter's value generally is an anti-pattern, and an untestable one at that (you can't trivially mock non-public methods, let alone on the class that is being tested). Show the code and request a testable redesign instead, though that may be a better fit at Code Review. – CodeCaster Sep 09 '16 at 20:40
  • The other functions are public. This is a batch program and it's purpose is to branch on a few different processes based on a list of config information. – user441521 Sep 09 '16 at 20:44

0 Answers0