You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to write an extension method to use with Check.ThatCode, however in my case I would like to do some setup before the lambda function provided gets called.
Currently when calling ThatCode the lambda function gets executed and the result, possible exception and execution time get stored so that the extension methods can Check against those.
However I would like to write my own check to use a mocking framework to test if a method was called on a object in a static context. The check might look something like this Check.ThatCode(() => StaticClass.Instance.Execute()).Not.CallsExecute()
However in order to do that I need to replace the object in StaticClass.Instance with one from my mocking framework BEFORE the code gets executed. Would it make sense to change how Check.ThatCode works to wait to execute the provided function until ExecuteCheck is called
The text was updated successfully, but these errors were encountered:
Thanks for a pretty clear description of your need.
This request is actually tricky: ExecuteCheck is called for every tests done on the code. Which means if we simply delayed the run until ExecuteCheck, the checked code could be run several time, which is not desirable.
The proper approach implies being able to provide custom code to be executed before and after execution. Alternatively and probably better, a chain of responsibility for ExecuteCheck
dupdob
changed the title
Check.ThatCode immidatly executes the lambda function before extension method is used
Check.ThatCode immediatly executes the lambda function before extension method is used
Jun 1, 2016
I would like to write an extension method to use with
Check.ThatCode
, however in my case I would like to do some setup before the lambda function provided gets called.Currently when calling
ThatCode
the lambda function gets executed and the result, possible exception and execution time get stored so that the extension methods can Check against those.However I would like to write my own check to use a mocking framework to test if a method was called on a object in a static context. The check might look something like this
Check.ThatCode(() => StaticClass.Instance.Execute()).Not.CallsExecute()
However in order to do that I need to replace the object in
StaticClass.Instance
with one from my mocking framework BEFORE the code gets executed. Would it make sense to change howCheck.ThatCode
works to wait to execute the provided function untilExecuteCheck
is calledThe text was updated successfully, but these errors were encountered: