3

I have the following interface

public interface IActionSecureExecuter
{
    void SecureExecuteOperation(Action action);

    T SecureExecuteOperation<T>(Func<T> action);
}

Now I want to mock the implementation so that it does executes the delegates that it gets as arguments. It was pretty simple with the first method:

m_Executer.SecureExecuteOperation(Arg.Invoke());

But I have troubles with the generic implementation of the second one. Is it possible to do something with that Func or I will have to do a setup for each T? I am afraid this is not possible according to that question but I am not 100% sure. This is what I did now:

private void SetupInvokeAction<T>()
{
    m_Executer.SecureExecuteOperation(Arg.InvokeDelegate<Func<T>>());
}

I call this function in each test method. But I would really like to place that in the setup.

Community
  • 1
  • 1
Ilya Chernomordik
  • 27,817
  • 27
  • 121
  • 207

0 Answers0