dimanche 8 mars 2015

How to unit test delegate was received in base class method?

I currently have a base service class that all my services extend. This is what one of the methods look like:



protected internal virtual T PerformServiceOperation<T>(Func<T> func)
{
try
{
return func.Invoke();
}

...
}


In the derived classes I call the method like this:



public AddGuestResponse AddGuest(AddGuestRequest addGuestRequest)
{
return PerformServiceOperation(() => AddGuestLogic(addGuestRequest));
}


I want to test AddGuest and ensure "AddGuestLogic" is being passed as a parameter in the base method? How do I achieve this with nSubstitute and nUnit. I don't think its possible?


Aucun commentaire:

Enregistrer un commentaire