“Short circuiting” void methods with Moq?

If the SaveItem() method is virtual or abstract, and you’re not setting Callbase = true, then the method should be re-implemented to do nothing by the mock.

You should be able to do:

mockDb.Setup(d => d.SaveItem(It.IsAny<object>())).Verifiable();

...  test here ...

mockDb.Verify();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)