How do I verify that method was NOT called in Moq?
Does it have something like AssertWasNotCalled?
UPDATE: Starting from Version 3.0, a new syntax can be us
Stolen from: John Foster's answer to the question, "Need help to understand Moq better"
One of the things that you might want to test is that the pay method does not get called when a person aged over 65 is passed into the method
[Test] public void Someone_over_65_does_not_pay_a_pension_contribution() { var mockPensionService = new Mock(); var person = new Person("test", 66); var calc = new PensionCalculator(mockPensionService.Object); calc.PayPensionContribution(person); mockPensionService.Verify(ps => ps.Pay(It.IsAny ()), Times.Never); }