2

I have code like this

public void Foo(...) 
{ 
   ...
   FooAsync(...);
   ...
}

private async void FooAsync(...)
{
   await Task.Run(() => Process(...));
}

private void Process(...)
{
   // slow process
}

I want to unit test Foo, and one of the things I want to test is that some method is called on some object (that I have access to) within the Process method. The problem is that the Process method gets called after the check is made in the unit test. How do I test this so that it behaves more synchronously?

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304

0 Answers0