When using Moq Verify() method invocation count, have failing test's error message contain actual method invocation count using Moq

本小妞迷上赌 提交于 2019-12-01 15:44:10

I don't know of a straight way to harvest the information in Moq3. what I would do is use a callback on the setup of Blink

  int count = 0;
  employee.Setup(e => e.Blink()).Callback(() => count++);

  ...
  employee.Verify(e => e.Blink(), Times.Exactly(1), "Moq.MockException: Invocation was unexpectedly performed " + count + " times, not 1 time: e => e.Blink()"); // Fails as expected
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!