Added checks in CoyoteRuntime.RunTestAsync() to check testMethod if it is either a Action<ICoyoteRuntime> or Func<ICoyoteRuntime, Task> delegate type before calling the runtime extension RunTest() method #509
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The runTest that acts as the top-level execution for the ControlledThread that is created in CoyoteRuntime.RunTestAsync first calls
if (this.Extension.RunTest(testMethod, out Task extensionTask))
before checking if testMethod is an Action or a Func.
When this.Extension is an ActorExecutionContext, then the RunTest method is implemented like so
However, the Action<T> and Func<T,Task> generic parameter 'T' is contravarient. So, if the testMethod is either an Action<ICoyoteRuntime> or a Func<ICoyoteRuntime, Task>, one of the condition tests will pass, and the method will be executed. Which is fine, but it masks/hides a possible condition where if the runtime extension is not an ActorExecutionContext instance and instead returns false, then the conditional checks in the runTest delegate for the ControlledThread will throw an exception stating that the test delegate type is unsupported even though the TestEngine.Create overloads allow and support such a test method.
There needs to be type checks in the testMethod prior to calling this.Extension.RunTest().