Hi,
I am writing a very simple test to verify that a private method is called when a public when is invoked.
Below is a sample that illustrates this.
using System;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
using TypeMock;
using TypeMock.ArrangeActAssert;
namespace UnitTests
{
public abstract class Foo
{
public void DoIt()
{
privateDoIt();
}
protected void privateDoIt()
{
}
}
[TestFixture]
public class FooFixture
{
[SetUp]
[Test, Isolated]
public void TestDoIt()
{
var f = Isolate.Fake.Instance<Foo>(Members.CallOriginal);
f.DoIt();
Isolate.Verify.NonPublic.WasCalled(f, "privateDoIt");
}
}
}
It seems simple enough but each time I run this test I unexpectedly get the following error:
TypeMock Verification: Method Mock0000Foo.privateDoIt() was expected but was not called
After toying with it I discovered that if I change the method accessibility from private to protected it works the way I would expect, that is to say it succeeds.
Can someone tell me what I might be doing incorrect?
I am using Isolator v5.3.0 on VS2008 with TestDriven.NET 2.19.2409.
Thanks,
Darin