Hi,
Isolate.Verify.GetTimesCalled is currently not available in the NonPublic API.
This problem can be solved using DoInstead:
public class UnderTest
{
public void TestedMethod()
{
for (int i = 0; i < 5; i++)
{
SubjectMethod();
}
}
private void SubjectMethod(){}
}
[TestClass, Isolated]
public class UnitTests
{
[TestMethod]
public void Verifying_TimesPrivateMethodWasCalled()
{
//Arrange
int counter = 0;
var underTest = new UnderTest();
Isolate.NonPublic.WhenCalled(underTest, "SubjectMethod").DoInstead(c=>
{
counter++;
c.WillCallOriginal();
});
//Act
underTest.TestedMethod();
//Assert
Assert.AreEqual(5, counter);
}
}