I have a class with a private function that dozens of other public functions use.
This private function just wrap other private functions that call to third party with try-catch
private T TryCatchCallWrapper<T>(Func<T> method)
{
try
{
Login();
return method();
}
catch (ConnectionException e)
{
switch (e.ConnectionReason)
{
case ConnectionReasonEnum.Timeout:
throw new ...
}
}
catch (XException e)
{
throw ...
}
}
I want to test this wrap function to be sure it catches all exceptions correctly, but I don't like to test it again for each public function that use it. (however, i want to verify they call to this function (like mock.Verify())
What is the best practice to deal with that?
One option is to extract the wrapped function to another class, but I am not sure it's good solution since the wrapped function usages and relevance are just in the current class. thanks!