I have an event as following
namespace MyProject
{
public class MyEvent
{
public MyEvent(int favoriteNumber)
{
this.FavoriteNumber = favoriteNumber;
}
public int FavoriteNumber { get; private set; }
}
}
And I have a method which raises this event.
using Caliburn.Micro;
//please assume the rest like initializing etc.
namespace MyProject
{
private IEventAggregator eventAggregator;
public void Navigate()
{
eventAggregator.PublishOnUIThreadAsync(new MyEvent(5));
}
}
If I using just PublishOnUIThread, the below code (in an unit test) is working fine.
eventAggregatorMock.Verify(item => item.Publish(It.IsAny<MyEvent>(), Execute.OnUIThread), Times.Once);
But how do I check for async version for the same?
eventAggregatorMock.Verify(item => item.Publish(It.IsAny<MyEvent>(), Execute.OnUIThreadAsync), Times.Once);
Facing trouble verifying the async method. Assume private Mock<IEventAggregator> eventAggregatorMock;
. The part Execute.OnUIThreadAsync
gives error 'Task Execute.OnUIThreadAsync' has the wrong return type
.
I also tried
eventAggregatorMock.Verify(item => item.Publish(It.IsAny<MyEvent>(), action => Execute.OnUIThreadAsync(action)), Times.Once);
But says, System.NotSupportedException: Unsupported expression: action => action.OnUIThreadAsync()
Thanks in advance.