You can try modifying your code to allow for asynchronous testing.
One approach you could take is to use TaskCompletionSource to signal the completion of the task in your test case. Here's an example of how you could modify your code to implement this approach:
private async Task<string> ProcessMonitor_OnProcessStopped(object sender, ProcessDetails processDetails)
{
await Task.Delay(500);
return "Value";
}
[TestMethod]
public async Task TestProcessMonitor_OnProcessStopped()
{
var tcs = new TaskCompletionSource<string>();
var processDetails = new ProcessDetails(); // Create process details as needed
var resultTask = ProcessMonitor_OnProcessStopped(null, processDetails);
resultTask.ContinueWith(t => tcs.SetResult(t.Result));
// Wait for the result or a timeout
var completedTask = await Task.WhenAny(tcs.Task, Task.Delay(1000));
Assert.AreEqual("Value", completedTask.Result);
}
This modified test case creates a TaskCompletionSource<string> to signal the completion of the task