I need to verify that a method is called, however it receives a parameter object which I can't determine at design time. I don't care what the parameter is, I just want to verify that the method is called.
So I would like to call something like this:
var subDao = new Mock<ISubscriptionSnapshotDao>();
subDao.Verify(x => x.Save(), Times.Exactly(1));
However ISubscriptionSnapshotDao.Save takes an object to save.
Save(Subscription entity);
Is there a way verify that Save has been called without knowing what the parameter will be?
Yes there is! If you know the Type of parameter the method expects.
It.IsAny<T>()
Try the following
subDao.Verify(x => x.Save(It.IsAny<Subscription>()), Times.Exactly(1));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With