0

I need to unit test methods, which are executing some actions on UI thread, like:

internal void MyMethod()
{
    Dispatcher.UIThread.Post(() =>
    {
       // some property set
       // some method call
    });
}

One thing I want to test is, if Dispatcher.UIThread.Post() was called (I'm preparing for some heavier refactorig). Is it possible to mock this Post() method, or entire Dispatcher class for this test in Avalonia?

user15123902
  • 123
  • 4
  • 1
    I'd suggest to replace calls to dispatcher with calls to some wrapper method and mock said wrapper instead. – kekekeks Oct 12 '21 at 15:45
  • This would be indeed a possible solution. Or I'm thinking to use IDispatcher interface for it's stub implementation, and use Dependency injection – user15123902 Oct 14 '21 at 08:01

0 Answers0