In my unit-tests I\'m mocking a protected method using Moq, and would like to assert that it is called a certain number of times. This question describes something similar f
To augment Ogata's answer, we can also verify a protected method that takes arguments:
testBaseMock.Protected().Setup(
"ChildMethod1",
ItExpr.IsAny(),
ItExpr.IsAny());
testBaseMock.Protected().Verify(
"ChildMethod1",
Times.Once(),
ItExpr.IsAny()
ItExpr.IsAny());
For instance, that would verify ChildMethod1(string x, string y)
.
See also: http://www.nudoq.org/#!/Packages/Moq.Testeroids/Moq/IProtectedMock(TMock)/M/Verify