Hi,
I'm using TypeMock 3.7.1 with .Net 2.0 and I'm trying to use DefaultBehavior.RepeatAlways() with chained natural mocks. I am getting the following exception that I don't think should be occuring:
Test method TestProject1.ProgramTest.method1Test threw exception: TypeMock.VerifyException: TypeMock Verification: Unexpected Call to MockintB.foo().
Here's some simple code to reproduce it. The code being tested is:
public static class classA
{
public static intB B
{
get
{
return null;
}
}
}
public interface intB
{
void foo();
void bar();
}
public class MyClass
{
public void method1()
{
classA.B.foo();
classA.B.bar();
}
}
And here is the unit test code:
[TestMethod()]
public void method1Test()
{
using (RecordExpectations recorder = RecorderManager.StartRecording())
{
recorder.DefaultBehavior.RepeatAlways();
classA.B.foo();
classA.B.bar();
}
MyClass myClass = new MyClass();
myClass.method1();
}
If I comment out the DefaultBehavior.RepeatAlways() then the test passes. However, in my real test I actually need the RepeatAlways behavior. Also, if I convert this to reflective mocks then it also passes (using ExpectAlways()).