You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cannot setup a callback on a protected method (by the way, Verify doesn't work either).
The code looks like following :
public abstract class AbstractClass
{
protected abstract void OneProtectedMethod();
}
public class OneClass : AbstractClass
{
protected override void OneProtectedMethod()
{
Console.WriteLine("Hello");
}
public void DoMethod()
{
OneProtectedMethod();
}
}
[Test]
public void should_call_protected_method()
{
var mock = new Mock<OneClass>();
mock.Protected().Setup("OneProtectedMethod").Callback(() => Console.WriteLine("Goodbye"));
var o = new OneClass();
o.DoMethod();
mock.Protected().Verify("OneProtectedMethod", Times.Once());
}
Am I doing anything wrong ? Or is there any issue ?
Thanks.
The text was updated successfully, but these errors were encountered:
Hello,
I cannot setup a callback on a protected method (by the way, Verify doesn't work either).
The code looks like following :
Am I doing anything wrong ? Or is there any issue ?
Thanks.
The text was updated successfully, but these errors were encountered: