0

I am writing the unit test for a method. I have properly configured all the setups. While debugging unit test it works and returns values as expected. But in assertion it still throws false.

Therefore, I am not able to understand why does VerifyAll throws false all the time? How to find out which setup failed the VerifyAll assert?

Karan Desai
  • 3,012
  • 5
  • 32
  • 66

1 Answers1

0

VerifyAll verifies that all your Setups were called. It sounds like you have a Setup that is not relevant to your test, hence your are getting the expected output, yet the VerifyAll fails because that Setup was never called.

When VerifyAll fails you will get an exception, and the reason is given there. For example, if I create an unused Setup in a test I get:

Moq.MockVerificationException : The following setups were not matched: IMyClass m => m.MyMethod()

Owen Pauling
  • 11,349
  • 20
  • 53
  • 64