From 473bb3cc1b813a9534fb64643e0007f175684fca Mon Sep 17 00:00:00 2001 From: Kevin Zehrer <103638980+kzdev-net@users.noreply.github.com> Date: Mon, 29 Jul 2024 10:40:41 -0500 Subject: [PATCH] Added checks in CoyoteRuntime.RunTestAsync() to check testMethod if it is either a Action or Func delegate type before calling the runtime extension RunTest() method because for an extension of type ActorExecutionContext, the RunTest method will gladly call one of those delegate types even though it is designed to only handle Action or Funcdelegate types, but Action and Func generics have a contravarient generic parameter, so ActorExecutionContext will indicate that the delegate was called fine, but other extension types (e.g. NullRuntimeExtension) will not call the methods, so the provided test method might only run if the ActorExecutionContext is the runtime extension, but the test method is not actually the expected type of delegate. --- Common/version.props | 2 +- Source/Core/Runtime/CoyoteRuntime.cs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Common/version.props b/Common/version.props index a7f29204a..82aa0c233 100644 --- a/Common/version.props +++ b/Common/version.props @@ -2,7 +2,7 @@ - 1.7.11 + 1.7.12 diff --git a/Source/Core/Runtime/CoyoteRuntime.cs b/Source/Core/Runtime/CoyoteRuntime.cs index 3b49da68f..2d9ee4073 100644 --- a/Source/Core/Runtime/CoyoteRuntime.cs +++ b/Source/Core/Runtime/CoyoteRuntime.cs @@ -361,7 +361,15 @@ internal Task RunTestAsync(Delegate testMethod, string testName) Action runTest = () => { Task task = Task.CompletedTask; - if (this.Extension.RunTest(testMethod, out Task extensionTask)) + if (testMethod is Action actionWithRuntime) + { + actionWithRuntime(this); + } + else if (testMethod is Func functionWithRuntime) + { + task = functionWithRuntime(this); + } + else if (this.Extension.RunTest(testMethod, out Task extensionTask)) { task = extensionTask; }