“Short circuiting” void methods with Moq?

前端 未结 1 1164
别那么骄傲
别那么骄傲 2020-12-29 03:55

my team has made the decision recently to use Moq as our mocking framework for its tremendous flexibility and highly readable syntax. As we\'re new to it, I\'m stumbling on

相关标签:
1条回答
  • 2020-12-29 04:36

    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();
    
    0 讨论(0)
提交回复
热议问题