I have an interface IBackgroundJobClient
which has an extension method Enqueue
void Enqueue<T>(this IBackgroundJobClient client, Expression<Action<T>> action);
and I call it like below
void schedule(int id)
{
_job.Enqueue<FileUploadService>(x => x.UploadFile(id));
}
using Moq
I am trying to verify if Enqueue is called
private Mock<IBackgroundJobClient> _jobClient = new Mock<IBackgroundJobClient>();
and in the test I am trying to verify that its called once
schedule();
_jobClient.Verify(x => x.Enqueue(It.IsAny<Expression<Action<FileUploadService>>>()), Times.Once);
below is the error I am getting
System.NotSupportedException : Invalid verify on an extension method: x => x.Enqueue(It.IsAny>>()) at Moq.Mock.ThrowIfVerifyExpressionInvolvesUnsupportedMember(Expression verify, MethodInfo method) in C:\projects\moq4\src\Moq\Mock.cs:line 780
How can I verify if method was called once